Re: Subroutines
Re: Subroutines
- Subject: Re: Subroutines
- From: "Arthur J Knapp" <email@hidden>
- Date: Mon, 08 Jan 2001 16:55:54 -0500
>
Date: Mon, 08 Jan 2001 11:41:38 -0500
>
From: "Stephen Gross" <email@hidden>
>
Subject: Subroutines
>
Is there a way to do subroutines in applescript?
>
on SubRoutineName()
>
commands
>
end SubRoutineName
>
>
If that works, how do I call the subroutine?
on SubRoutineOne()
-- commands
end SubRoutineOne
on SubRoutineTwo( parameterOne, parameterTwo )
-- commands
end SubRoutineTwo
set variableOne to SubRoutineOne()
set variableTwo to SubRoutineTwo( "Howdy", 3.14 )
tell application "Whatever"
set variableOne to my SubRoutineOne() -- my
set variableTwo to SubRoutineOne( true, false ) of me -- of me
end tell
It is importent to "tell" the current tell-statement application
that a subroutine belongs to your script, and is not a command of
the application, using the "my" or "of me" syntax.
You may also wish to make use of script objects:
script HelloWorld
property Guy1 : "Hello "
property Guy2 : "World"
on SayHello()
display dialog Guy1 & Guy2
end SayHello
end script
SayHello() of HelloWorld
-- or:
tell HelloWorld
SayHello()
end
--
{
Arthur J Knapp, of STELLARViSIONs ;
http://www.STELLARViSIONs.com ;
mailto:email@hidden ;
http://developer.apple.com/techpubs/
macos8/InterproCom/AppleScriptScripters/
AppleScriptLangGuide/
}