Re: what the heck - text manipulation script
Re: what the heck - text manipulation script
- Subject: Re: what the heck - text manipulation script
- From: "John C. Welch" <email@hidden>
- Date: Tue, 18 Jul 2006 13:29:49 -0500
- Thread-topic: what the heck - text manipulation script
Title: Re: what the heck - text manipulation script
On 7/18/06 11:40, "Natalie Lambert" <email@hidden> wrote:
> It is supposed to be a tab between "05" and "@St.
> Louis" but that isn't really the problem. Even if I do
> this....
>
> set AppleScript's text item delimiters to ""
>
> set x to "OCT 05 @St. Louis" as text
> set v to text item 2 of x
> set y to word 4 of x
> return {v, y}
>
> my result is {"C", "St"}
>
> why isn't the script seeing the @ and period as the
> part of the word with "St"? Even if I change my
> delimiters to a tab or a space the script ignores the
> period and see the @ as seperate even though there are
> no spaces between. I have told the script "as Text"....
First, you don't need the "as text" for the text string, the quotes take care of that for you.
Secondly, for raw tabs, you need to set the initial code to:
set AppleScript's text item delimiters to "\t”
set x to "OCT\t05\t@St.\tLouis"
which, when compiled looks like:
set AppleScript's text item delimiters to " "
set x to "OCT 05 @St. Louis"
the tabs are not shown, but there. (If you have Script Debugger, watching what is really happening is TONS easier) So:
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set x to "OCT 05 @St. Louis"
set v to text item 3 of x
set y to the third word of x
set AppleScript's text item delimiters to oldDelims
return {v, y}
Note that while v and y both point to the third text item and the third word respectively, the results back are quite different.
--
"A slipping gear could let your M203 grenade launcher fire when you least expect it. That would make you quite unpopular in what is left of your unit."
Army's magazine of preventive maintenance.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden