Re: Still more strange things …
Re: Still more strange things …
- Subject: Re: Still more strange things …
- From: Axel Luttgens <email@hidden>
- Date: Wed, 21 Jan 2004 11:41:25 +0100
Jean-Baptiste wrote:
I've encountered the following in a script :
set theArray to {}
repeat 4 times
set end of theArray to theArray
end repeat
--> {{, , , }, {, , , }, {, , , }, {, , , }}
What does it mean ?
Since I couldn't imagine what those "" are for, I first tried your code
here; the script just enters in an endless loop, and thus doesn't
provide any results.
What is your version of AppleScript? (I'm here on OS 10.3.2/AS 1.9.3)
What are those "" for?
Anyway, try that variant:
set theArray to {}
repeat 4 times
copy theArray to end of theArray
end repeat
--> {{}, {{}}, {{}, {{}}}}
Does this appear less astonishing to you?
Well, that's the difference between the "set" and the "copy" commands
when applied to lists, records, dates and script objects.
The first one uses data sharing (this is AppleScript's terminology),
while the second one works through copies.
Intuitively, while writing "set end of theArray to theArray", you are
adding to theArray a new element that happens to be theArray itself.
If you haven't done it yet, I would first suggest to go back to the ASLG
and rehave a look at what is said about "set", "copy" and "data sharing".
There has also been a thread on this list that started on september 9th,
2003 with the message "Dates gone wild"; might prove very useful as lots
of people shared their understanding about those matters.
HTH,
Axel
_______________________________________________
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.