Re: By nice to the Windows user come to AppleScript please :-)
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