AppleScript: The Missing Manual

B.8. Subroutines

In HyperTalk, you define a subroutine like this:

on triple someNumber return someNumber * 3 end triple

And run it like this:

triple 10 --Would return 30

In AppleScript, however, you define a subroutine like this (Section 5.2.5):

on triple(someNumber) return someNumber * 3 end triple

And run it like this:

triple(10)

As you can see, the difference with HyperTalk is that you don't type parentheses around the value you want to perform a subroutine on.

Категории