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

Re: Handlers first?


  • Subject: Re: Handlers first?
  • From: Stan Cleveland <email@hidden>
  • Date: Mon, 24 Oct 2011 11:23:04 -0700

On Oct 22, 2011, at 1:36 AM, Shane Stanley wrote:

> There is at least one case in AS where script objects need to be declared before they are called -- or, at least, there was.

A script object inside a handler must be defined before it is called. If not in a handler, a script object can be can be called from anywhere, before or after its definition.

This fails:
    sayHello()
    on sayHello()
        run script s -- or just 'run s'
        script s
            display dialog "Hello."
        end script
    end sayHello

This works:
    sayHello()
    on sayHello()
        script s
            display dialog "Hello."
        end script
        run script s -- or just 'run s'
    end sayHello

The command "run script" from Standard Additions is technically the correct one to use. It surprises me that the "run" command even works! AS seems to be fudging its own "run" command, which is intended to run applications, not script objects. (I'm still on SL, BTW, so don't know how any of this works on Lion.)

Stan C.

 _______________________________________________
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

References: 
 >Handlers first? (From: Robert Poland <email@hidden>)
 >Re: Handlers first? (From: Shane Stanley <email@hidden>)
 >Re: Handlers first? (From: Stan Cleveland <email@hidden>)
 >Re: Handlers first? (From: David Ferrington <email@hidden>)
 >Re: Handlers first? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Remote Disks
  • Next by Date: Get length of audio/video files
  • Previous by thread: Re: Handlers first?
  • Next by thread: Breaking out of recursive handler and returning result does not happen
  • Index(es):
    • Date
    • Thread