• 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: how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how?


  • Subject: Re: how?
  • From: Chris Page <email@hidden>
  • Date: Thu, 14 Jan 2010 17:06:15 -0800

On Jan 13, 2010, at 10:50 PM, Paul Scott wrote:

repeat -- once
   ....
   if ...
      exit repeat
   end if
   ...
   exit repeat
end_repeat

Another way to accomplish this is with a local function. AppleScript supports local functions via a slight indirection: you can define local script objects and call their handlers.

on F()
-- ...
script S
-- ...
if x then return
-- ...
end script


tell S to run


-- ...
end F


Using the implicit “run” handler shortens the overall code slightly. You can also name handlers explicitly, of course:

on F()
-- ...
script S
on G()
-- ...
if x then return
-- ...
end G
end script


S's G()


-- ...
end F


Unlike a “repeat 1 times” loop, this approach enables the local function to return values, so you don’t have to communicate by setting variables.

-- 
Chris Page

 The other, other AppleScript Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: how?
      • From: Paul Scott <email@hidden>
References: 
 >Re: how? (From: Paul Berkowitz <email@hidden>)
 >Re: how? (From: Paul Scott <email@hidden>)

  • Prev by Date: Re: how?
  • Next by Date: Re: how?
  • Previous by thread: Re: how?
  • Next by thread: Re: how?
  • Index(es):
    • Date
    • Thread