Re: dumb question but vital
Re: dumb question but vital
- Subject: Re: dumb question but vital
- From: Nigel Garvey <email@hidden>
- Date: Tue, 10 Jun 2003 11:31:59 +0100
Andrew Oliver wrote on Mon, 09 Jun 2003 17:16:39 -0700:
>
set x to {thisfilename}
>
>
to maintain its list class.
>
>
Secondly, when embedding lists, you need to:
>
>
set y to y & {x}
Absolutely right thus far. To amplify what Helmut said:
set y to {}
set x to thisfilename -- say "My file"
set y to y & x
--> x is automatically coerced to list for concatenation to list y,
--> so the concatenation performed is {} & {"My file"}.
--> The result is a new, combined list {"My file"}.
set y to {}
set x to {thisfilename}
set y to y & x
--> Here x is already a list, so no coercion takes place
--> and the concatenation performed is {} & {"My file"}, as above.
--> The result is a new, combined list {"My file"}.
set y to {}
set x to {thisfilename}
set y to y & {x}
--> The list x is in another list. *That* list is concatenated to y.
--> The concatenation performed is {} & {{"My file"}}.
--> The result is a new, combined list {{"My file"}}.
However, unless you do actually want to concatenate two lists together,
or you specifically want to create a new list, a better way to append an
item to the end of a list is simply to use 'set end of':
set y to {}
set x to {thisfilename}
set end of y to x
--> The list x is appended to the end of the existing list y.
--> y is still the same list, but with an extra item.
--> {{"My file"}}
NG
_______________________________________________
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.