[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] That Do Script thing



At 21:54 -0700 9/7/00, Enrique Terrazas wrote:
>Yes.  It looks like the problems may be related to how applescript
>interprets what you are trying to do.  For example,
>
>set myList to "print join '|', @ARGV" & {"a", "b"}
>
>yields -> "print join '|', @ARGVab"
>
>so it looks like applescript is coercing {"a", "b"} to a string before
>performing the & operation.  However,
>
>set myList to {"a", "b"} & "print join '|', @ARGV"
>
>yields -> {"a", "b", "print join '|', @ARGV"}
>
>so it looks like applescript is coercing "print join '|', @ARGV" to a list
>before performing the & operation.  This must be tied to which comes first.
>Workarounds are being explicit so that applescript doesn't have to guess
>which you want, a list or a string:

In AppleScript, the item on the left side of a & determines the type of the
result.

set a to 3 & 4
set b to "3" & 4
set c to 3 & "4"
set d to 3 & "4" & 5

{a, b, c, d}
  -->{{3, 4}, "34", {3, "4"}, {3, "4", 5}}

a is a list because 3 is not a string.
b is a string because "3" is a string.
c is a list, and note that "4", which could be coerced to a number, isn't
d is the way it is because & is applied left to right, so the second & is
{3, "4"} & 5

AppleScript records, if you have one on the left, make life more
fun...experiment.

   --John
-- 
John Baxter   jwblist@olympus.net      Port Ludlow, WA, USA

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org