• 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: By nice to the Windows user come to AppleScript please :-)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: By nice to the Windows user come to AppleScript please :-)


  • Subject: Re: By nice to the Windows user come to AppleScript please :-)
  • From: has <email@hidden>
  • Date: Fri, 11 Jan 2002 10:52:37 +0000

Paul Berkowitz wrote:

>repeat with someItem in theItems
>
>end repeat
>
>
>Frequently, and usually when the list consists not of application objects
>but of strings or numbers - just a pre AppleScript list - you run into
>problems because the item is not evaluated. (It is 'item x of {item 1 of
>someItems, item 2 of someItems, ...}.)

Yup. As you indicate, what you actually get with the "repeat with x in y"
construct is actually a reference to an object in y, *not* the object
itself. This is stated in the ASLG, btw, though not made obvious enough
imho.

It's one of those counter-intuitive 'gotchas' that can catch out novices
all too easily, many of whom are likely to use repeat loops long before
they learn what a reference is. (I know it caught me...:p)

The problem seems compounded as follows:

repeat with x in {1, 2, 3}
x
end repeat
--> item 3 of {1, 2, 3} -- a reference, yes?

repeat with x in {1, 2, 3}
x's class
end repeat
--> integer -- except it swears its just an integer... hmm

Perhaps there's a good reason for this behaviour, but I'm not sure what it
must be. (Unfortunately, I suspect this is just the sort of thing that
gives AS a reputation for being quirky and unpredictable.:/)

has


  • Follow-Ups:
    • Re: By nice to the Windows user come to AppleScript please :-)
      • From: Andy Satori <email@hidden>
  • Prev by Date: HD name change for X
  • Next by Date: Differentiating between "A1", "A12", etc. - my solution
  • Previous by thread: Re: HD name change for X
  • Next by thread: Re: By nice to the Windows user come to AppleScript please :-)
  • Index(es):
    • Date
    • Thread