Re: Text and Offset Peculiarities ???
Re: Text and Offset Peculiarities ???
- Subject: Re: Text and Offset Peculiarities ???
- From: Deivy Petrescu <email@hidden>
- Date: Sun, 15 May 2011 14:12:31 -0400
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
Michael,
"\n" is a return character. Its ascii number is 10.
So try
set myOffset to offset of (ASCII character myAscii) & (ASCII character 10) &" Departing 0" in myText
adjust for spaces if necessary
If you want you can go to preferences and turn off the "Escape tabs and line breaks in strings" in the Edit tab.
Deivy Petrescu
email@hidden
_______________________________________________
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