SRT


 

SRT>Subroutine_Name

 

Identifies the start of a Subroutine block.  Use End to end the subroutine.

 

Subroutines can be nested.  Subroutines can be located anywhere within the script.

 

In almost all circumstances subroutines should be allowed to end properly and it is best practice to do so.  In other words execution should always continue on to the subroutine's End statement.  While it is possible to jump out of a subroutine using a Goto statement the scope of execution will remain inside the subroutine unless and until execution returns to the subroutine and the subroutine's End statement is reached.  This is most noticeable when using an OnEvent event handler.  If, for example, a KEY_DOWN event is set to fire a subroutine and code is allowed to jump out of the subroutine, OnEvent won't know that the subroutine has ended and therefore no subsequent KEY_DOWN events of the same type will fire.  If you do need to cause execution to jump to a label after the subroutine has terminated use the SkipLabel command.

 

By default variables have global scope.  Variables can be set to have local scope by setting LOCALVARS to 1.  See topic: Variable Scope.

 

See also Gosub, END, SkipLabel

 

Example

 

Gosub>EnterName

Gosub>CloseApp

 

//// Subroutines Below ////

 

SRT>FocusApp

   SetFocus>Data Entry Screen

End>FocusApp

 

SRT>EnterName

   Gosub>FocusApp

   Send>Firstname

   Press Tab

   Send>Surname

   Press Enter

End>EnterName

 

SRT>CloseApp

   Gosub>FocusApp

   Press ALT

   Press F4

   Release ALT

End>CloseApp