• 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: Paul Berkowitz <email@hidden>
  • Date: Thu, 10 Jan 2002 11:09:01 -0800

On 1/10/02 10:29 AM, "Andy Satori" <email@hidden> wrote:

> Is there an equivalent construct to the VBS
> 'for each item in items ... Next'
> Syntax in AppleScript?
>

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, ...}.) You can deal with that either by
using

repeat with someItem in theItems
doSomethingWith contents of someItem
end repeat

using 'contents of'. But if tiy always use this construct:

repeat with i from 1 to (count someItems)
set someItem to item i of someItems
--rest of script
end repeat

you will never, ever have any problems. so it's often simpler to stick in
the extra line using this method than worry about whether you have to check
the other method in run-time.

Now, perhaps you're wondering how to do

If somethingOrOther Then Next i (or however that is in VBA), in other
words, how to move on to the next iteration in midstream. That doesn't exist
as such in pure AppleScript, but Ray Robertson invented a wonderful
technique that does it:

repeat -- either method above
repeat 1 times
--your script
if somethingOrOther then exit repeat
--more stuff
end repeat
end repeat


--
Paul Berkowitz


References: 
 >By nice to the Windows user come to AppleScript please :-) (From: Andy Satori <email@hidden>)

  • Prev by Date: Re: Tell OS X Application...
  • Next by Date: Re: By nice to the Windows user come to AppleScript please :-)
  • Previous by thread: By nice to the Windows user come to AppleScript please :-)
  • Next by thread: Re: By nice to the Windows user come to AppleScript please :-)
  • Index(es):
    • Date
    • Thread