Re: coerce shell script output to AS datatypes?
Re: coerce shell script output to AS datatypes?
- Subject: Re: coerce shell script output to AS datatypes?
- From: has <email@hidden>
- Date: Tue, 27 Aug 2002 11:51:53 +0100
john mead wrote:
>
I want to return an applescript list from the output
>
of a shell script. The shell script just prints a list
>
of comma demimited, quoted strings {wrapped in curley
>
braces} to stdout. I was expecting to be able to
>
coerce this result to an applesctipt list, however the
>
result looks like this:
>
>
--> "{\"Thing one\", \"Thing two\"}"
I think you've misunderstood how string->list coercion works in
AppleScript. You might want to try reading up on the topic in something
like the AppleScript Language Guide.
>
Is there a know way to return
>
applescript datatypes from a shell script
This seems unlikely, as the shell knows as much about AppleScript as
AppleScript knows about the shell. (I'm no shell master though, so I can't
say for sure.)
Anyway, while you could create a list by compiling executing your string
using Standard Additions' "run script", this is about the least efficient
or practical way of solving the problem. It would be much easier if you
print your values in [eg] return delimited form:
"Thing one
Thing two"
and tokenise this using 'paragraphs of theString'. [1] (If you're using
some other character/string to delimit your values, then use AppleScript's
text item delimiters to break it up instead.)
HTH
has
[1] Note that one of AppleScript's best-known faults is its inability to
break a string into more than approx. 4000 items, and will throw an error
[stack overflow] if you exceed this [arbitrary] limit. If this is a
possibility, it can be worked around with a bit of extra code - e.g. the
everyItemLib library on my site will do this for you.
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.