Section B.8. Subroutines


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.



AppleScript. The Missing Manual
AppleScript: The Missing Manual
ISBN: 0596008503
EAN: 2147483647
Year: 2003
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net