Re: Tanaka's osax 2.01- MT Parse command ??
Re: Tanaka's osax 2.01- MT Parse command ??
- Subject: Re: Tanaka's osax 2.01- MT Parse command ??
- From: email@hidden
- Date: Wed, 24 Apr 2002 10:29:18 EDT
Bill,
It's a bit tricky - read Tanaka's dictionary carefully. The [MT Parse]
command produces a list of lists. Try this to understand better:
tell application "Finder"
set allParts to "partOne@partTwo@partThree#partA@partB@partC"
set prsr to "@"
set lndlm to "#"
set partsList to (MT Parse allParts item delimiter prsr line delimiter
lndlm)
display dialog (length of item 1 of partsList)
-->"3"
try
display dialog partsList as integer -- deliberate error
on error errmsg
display dialog errmsg -- see the created data structure
end try
end tell
Note that if you MT Parse "partOne@partTwo@partThree", the result will be
{{"partOne","partTwo","partThree"}}, but the above try block will make it
look like {"partOne","partTwo","partThree"} (at least OMM 9.1+1.5.5 - maybe
some silent coercion is happening). Use the event log as another way to view
the data structure of such beasts.
Jeff Baumann
email@hidden
www.linkedresources.com
In a message dated 4/23/02 5:56:37 PM, Bill Christens-Barry wrote:
>
I'm trying to use Tanaka's osax 2.0.1 to parse a string into a list
>
of parts, with an unexpected result:
>
>
tell application "Finder"
>
set allParts to "partOne@partTwo@partThree" as string
>
set prsr to "@"
>
set thePartsList to (MT Parse allParts item delimiter prsr)
>
display dialog (length of thePartsList)
>
-->"1"
>
display dialog (thePartsList as text)
>
-->"partOnepartTwopartThree"
>
end tell
>
>
I expected to get a list containing the 3 items
>
{"partOne","partTwo","partThree"}, but was surprised by the effective
>
removal of the parsing string. I've tried a variety of explicit
>
coercions (to text, list, etc) without getting what I expected.
>
>
I'm using MacOS 8.6 and the Applescript 1.3.7 extension. Any examples
>
of how to do this successfully?
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.