AppCtrlScript

MAY Computer

Help

SUB

Applies to  

AppCtrlScript (Module: wmACScr1.dll)

Group  

Structures

See also  

CALL, RETURN, EXIT, LABEL

Definition of a subroutine that can be called from anywhere in the script by only specifying the name.

In general when running a script it is started by calling the SUB Main subroutine. If such a subroutine does not exist, the script execution starts with the first line and/or first subroutine that is found.

You cannot define subroutines within other subroutines. They must be all defined on top level. When reaching an END SUB statement the current subroutine is left and processing continues with the next line from where the subroutine has been called.

Important note: If you do not have a SUB Main but have other subs then you have to put an EXIT or QUIT statement before the first SUB statement. Otherwise the first subroutine is called automatically. Further SUB statements may not be indented.

Syntax

SUB <Name>
<...>
END[ SUB]

Part

Description

<Name>

A name of the subroutine which should not contain spaces.

<...>

One or more script lines

Sample

SUB Test
MSGBOX "This is a test."
END SUB
SUB Main
Test
END SUB