Re: dumb question but vital
Re: dumb question but vital
- Subject: Re: dumb question but vital
- From: Kai <email@hidden>
- Date: Tue, 10 Jun 2003 09:59:17 +0100
on Mon, 09 Jun 2003 17:32:58 -0600, Mick <email@hidden> wrote:
>
why can I not make a list of lists? I have been trying, desperately to get a
>
list of file names, make each name into a list and then concatenate those
>
lists into a list.
>
>
Each time I do it the concatenation seems to put the names back as strings.
>
>
for example
>
>
set x to {}
>
set x to thisfilename (where filename is a string)
>
class of x -- returns "list"
Are you sure the variable 'thisfilename' was a string, Mick?
--------------------------
set thisfilename to "test"
set x to {}
set x to thisfilename
class of x
--> string
--------------------------
However...
--------------------------
set thisfilename to {"test"}
set x to {}
set x to thisfilename
class of x
--> list
--------------------------
As Andrew pointed out, the statement 'set x to {}' doesn't really achieve
anything - because it's immediately superseded by 'set x to thisfilename'.
>
but
>
>
set x to {}
>
set y to {}
>
set x to thisfilename
>
set y to y & x
>
class of item 1 of y -- returns "string"
The concatenation operator merges the items of two lists into a single list,
rather than making one list a value within the other list. However, besides
the good advice you've already had, don't forget that you can also add one
list to another (without merging the two) like this:
--------------------------
set x to {"test"}
set y to {}
set y's end to x
y's last item's class
--> list
--------------------------
(If required, you could use <set y's beginning to x> instead.)
--
Kai
_______________________________________________
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.