NairnFEAMPM Icon

Subroutines

The commands can include subroutines. All subroutines must be defined at the start of the commands. The commands that get executed and will call the subroutines must start with the first command after the last subroutine definition.

A subroutine, which can be called with a GoSub command, is defined as follows:

Sub subname #arg1,#arg2,...,#argn
  (subroutine commands)
    .
    .
    .
  return
. . . EndSub

where

Notes

  1. See the GoSub command for information on calling subroutines.
  2. All variables are global variables. Thus subroutines can use variables set in the main commands and the main commands can access variables defined in the subroutines including subroutine arguments. If a subroutine argument matches a variable from the main commands, calling the subroutine will overwrite that value.
  3. Subroutines can be nested which means subroutines can call any other subroutines with GoSub commands.