Re: list of lists as arrays - creating?
Re: list of lists as arrays - creating?
- Subject: Re: list of lists as arrays - creating?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 02 Apr 2002 00:40:24 -0800
On 4/1/02 11:53 PM, "email@hidden" <email@hidden> wrote:
>
Specific Question: does a list of lists (i.e. - a 2 dimensional array) have
>
to be dimensioned in some way in order to bring it into existance?
>
>
attempted sample code:
>
>
set OurFileWidth to 100
>
set OurFileHeight to 100
>
try
>
set TheTestArray to {{}, {}}
>
repeat with Width from 1 to OurFileWidth
>
repeat with Height from 1 to OurFileHeight
>
set item Height of item Width of TheTestArray to "0"
>
end repeat
>
end repeat
>
on error
>
display dialog "Wasn't able to fill the array"
>
end try
>
>
always generates the dialog box.
Yes, you need to populate it with the sublists first. I think this is what
you want:
-----------
set OurFileWidth to 100
set OurFileHeight to 100
try
set TheTestArray to {}
repeat OurFileWidth times
set end of my TheTestArray to {}
end repeat
repeat with Width from 1 to OurFileWidth
repeat OurFileHeight times
set end of item Width of my TheTestArray to "0"
end repeat
end repeat
on error
display dialog "Wasn't able to fill the array"
end try
---------------
[Side issue: The two 'my's in there (at least the second one) make it _much_
faster, if that's what you want. 'my TheTestArray' won't work in a handler,
however, unless TheTestArray was defined at the top level of a script as a
property or global, or passed as a parameter to the handler. You can use
script objects within handlers to do the same, thanks to a discovery of
Serge Belleudy-d'Espinose on the MacScrpt list. The 'my' in main scripts is
a refinement of Nigel Garvey's. Ask if you want to know the details about
handlers.]
--
Paul Berkowitz
_______________________________________________
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.