• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Text and Offset Peculiarities ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text and Offset Peculiarities ???


  • Subject: Re: Text and Offset Peculiarities ???
  • From: Deivy Petrescu <email@hidden>
  • Date: Tue, 17 May 2011 09:00:22 -0400

On May 16, 2011, at 3:58 AM, Wayne Melrose wrote:

>
> Le 16 mai 2011 à 02:10, Deivy Petrescu a écrit :
>
>> On May 15, 2011, at 2: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
>>>>
>>>> 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.
>>>
>>> Hello Deivy
>>>
>>> The OP wrote that the script returned myAscii with the value 63 which means a question mark.
>>> This is why in my test I inserted a question mark just before the searched string.
>>>
>>> I don't understand how the "/n" may appear in such a case.
>>>
>>> Yvan KOENIG (VALLAURIS, France) 15 mai 2011 20:20:26
>>>
>> Hi Yvan,
>> the op wrote : (text (myOffset - 1) of myText
>> see the -1, it takes not the last but the penultimate character of the sentence.
>> The last character is the return… or \n.
>>
>  text (myOffset -1) is the character just before the string " Departing 0"
> It's exactly what I did.
>
> Yvan KOENIG (VALLAURIS, France) 16 mai 2011 09:42:44

Yvan,
I see what you are saying and may be you are right.
But as soon as I saw -1 and a "\n" I thought that the OP forgot that the last character of a line is a line feed (thanks Nigel) or return.
I thought that that was the problem.



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

References: 
 >Text and Offset Peculiarities ??? (From: Michael D Mays <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: Deivy Petrescu <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: KOENIG Yvan <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: Deivy Petrescu <email@hidden>)
 >Re: Text and Offset Peculiarities ??? (From: Wayne Melrose <email@hidden>)

  • Prev by Date: Re: tell app, name in string var
  • Next by Date: Re[2]: tell app, name in string var
  • Previous by thread: Re: Text and Offset Peculiarities ???
  • Next by thread: Re: Text and Offset Peculiarities ???
  • Index(es):
    • Date
    • Thread