Re: Text and Offset Peculiarities ???
Re: Text and Offset Peculiarities ???
- Subject: Re: Text and Offset Peculiarities ???
- From: Michael D Mays <email@hidden>
- Date: Sun, 15 May 2011 16:22:44 -0500
I am really missing the point or you guys are.:)
I find the location of a string with offset
I take that location and decrement it by 1
I use ASCII to tell me what that character is
I concatenate ASCII's results before the string which was initially found
Offset says it cannot find that string.
Is it possible that ASCII is just returning the low byte of a non printable multibyte character but offset is expecting all the bytes of the non printable character?
I wrote a handler
tell application "Safari"
set myText to the text of document 1
set myOffset to offset of " Departing " in myText
end tell
tell application "TextEdit"
set tt to ""
set lowerLimit to myOffset - 10
set upperLimit to myOffset + 10
repeat with i from lowerLimit to upperLimit
set tt to tt & i & " " & (text i of myText) & (ASCII number (text i of myText)) & "\n" as text
end repeat
set ttt to text lowerLimit thru upperLimit of myText
set the text of document 1 to tt & "\n\n\n" & ttt
end tell
with the following text
1944 p112
1945 32
1946 O79
1947 n110
1948 l108
1949 y121
1950
10
1951
10
1952
10
1953 63
1954 32
1955 D68
1956 e101
1957 p112
1958 a97
1959 r114
1960 t116
1961 i105
1962 n110
1963 g103
1964 32
p Only
Departing
After the three returns (1950-1952) there is a non-printable character at 1953. ASCCII is returning only 'part' of it. That part isn't sufficient for offset to match it.
Michael
On May 15, 2011, at 1:20 PM, KOENIG Yvan wrote:
>
> Le 15 mai 2011 à 20:12, Deivy Petrescu a écrit :
>
>>
>>
>> On May 15, 2011, at 1:46 PM, Michael D Mays wrote:
>>
>>> I have this script
>>>
>>> tell application "Safari"
>>> set myText to the text of document 1
>>> set myOffset to offset of " Departing 0" in myText
>>> set myAscii to ASCII number (text (myOffset - 1) of myText)
>>> set myOffset to offset of (ASCII character myAscii) & " Departing 0" in myText
>>> end tell
>>>
>>> The first offset command finds a match >1 but I run it the result (second offset command) is 0 ???
>>>
>>> ASCII character myAscii is 63. When I look at myText in the replies pane of AppleScript Editor what I see is
>>> /n Departing
>>> If I say
>>> set myOffset to offset of "/n Departing 0" in myText
>>> the result is 0.
>>>
>>> Any ideas as to what is happening or what I am doing wrong?
>>>
>>> Thanks,
>>> Michael
[clip]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden