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

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/
}


  • Prev by Date: Re: Text String to Command??
  • Next by Date: Re: Reading Lists and Records from Disk Files
  • Previous by thread: Re: Subroutines
  • Next by thread: Getting the username from NDS OSAX
  • Index(es):
    • Date
    • Thread