Re: Functionality of delimiters
Re: Functionality of delimiters
- Subject: Re: Functionality of delimiters
- From: KOENIG Yvan <email@hidden>
- Date: Wed, 23 Jan 2008 02:08:19 +0100
Le 23 janv. 2008 à 01:31, Jim Skibbie a écrit :
I have a question about delimiters in Tiger vs. Leopard as it
relates to parsing a string with an underscore “_” in it.
In Tiger, according to a book called “AppleScript – The
Comprehensive Guide to Scripting and Automation on Mac OS X” by
Hanaan Rosenthal, pg 66, it says there are a certain set of
characters that are considered words. Among them are & * + > < @ \
^ _ ` | , etc. and the underscore symbol is one of those.
As an example:
words of “you_me”
returns {“you “ , “_”, “me”}
This doesn’t work in Leopard. If you do the same command, you get
returns {“you_me”}
One item, not three. If you use some other symbols, for example,
words of “you&me”, the result in Tiger is:
Tiger {“you”, “&”, “me”}
In Leopard you get {“you” , “me”} and the ampersand has
vanished.
I have several scripts that attempt to parse a filename that looks
something like this:
set filename to “1234567890_9999999999 V1 3D.eps”
In Tiger, the current script says
set A to word 1 of filename and get back “1234567890”
In Leopard, the same command returns “1234567890_999999999”
Are scripts for Tiger supposed to be compatible in Leopard without
having to rewrite a bunch of stuff?
Do I need to do a bunch of front end delimiter changing and parsing
to get the same effect as I get in Tiger or am I missing something?
Thanks.
As the way a text is analyzed in words differs with the language
setting, I never rely upon words.
set filename to “1234567890_9999999999 V1 3D.eps”
set applescript's text item delimiters to "_"
set A to item 1 of (text items of filename)
set applescript's text item delimiters to ""
Always works .
Yvan KOENIG _______________________________________________
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