• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Still more strange things …
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Still more strange things ?
      • From: Emmanuel <email@hidden>
References: 
 >Still more strange things … (From: Jean-Baptiste <email@hidden>)

  • Prev by Date: Re: Coerce to 'alias list'
  • Next by Date: Re: Still more strange things ?
  • Previous by thread: Still more strange things …
  • Next by thread: Re: Still more strange things ?
  • Index(es):
    • Date
    • Thread