Creating a Subroutine by Typing SUBROUTINE
You can insert this command by typing SUBROUTINE in the Edit window's Command mode, and then pressing TAB. Once the command is inserted, you will need to specify the subroutine's name and any arguments it has. See the subroutine syntax and example below for this information.
Type the ENDSUB command and press TAB to end the command block. Any Edit window commands placed within this command block will be considered part of the subroutine and will be executed when the subroutine is called.
Creating a Subroutine by Using the Subroutine Menu Item
Select Insert | Flow Control Command | Subroutine from the submenu. This displays the Subroutine Creation dialog box. For information on this dialog box, see the "Understanding the Subroutine Creation Dialog Box" topic.
Subroutine Creation dialog box
Give the subroutine a name by typing it in the Name box. The name is limited to 180 or fewer characters. If you enter 181 or more characters a "Line too long" error message appears.
When you click the OK button, the name is automatically shortened to the first 180 characters, and the Subroutine Creation dialog box closes.
If your subroutine uses arguments (place holders for information passed into the subroutine), add them one by one by clicking the Add Argument button. The Argument Edit dialog box appears. For information on this dialog box, see the "Understanding the Argument Edit Dialog Box" topic.
Argument Edit dialog box
Give your argument a name by typing it in the Name box.
Give your argument a default value by typing it in the Value box. The subroutine will use the default value if no values are passed into the subroutine from the CALLSUB statement. Valid argument values can be numeric values, variables, text strings, and feature names.
If you want to give the argument a description, type it in the Description box.
Click OK in the Argument Edit dialog box to create the argument.
Repeat steps 3 through 7 for each argument you want in your subroutine.
Click the OK button in the Subroutine Creation dialog box to finish creating your subroutine. This subroutine will appear inside the Edit window with any defined arguments.
End your subroutine by selecting the Insert | Flow Control Command | End Sub menu option. This places an ENDSUB/ command in the Edit window, completing the subroutine's command block. Any other measurement routine commands you want in your subroutine must be added inside the subroutine's command block, before the ENDSUB command.
Syntax for a Subroutine Command Block
The Edit window command line syntax for a sample subroutine command block would read:
SUBROUTINE/<Name>,
<A1> = <Arg1> : <Description>,
<A2> = <Arg2> : <Description>,
=
<Commands>
ENDSUB/
SUBROUTINE/ is the command used to start the subroutine command block.
<Name>= The name of the subroutine. The name is limited to 256 or fewer characters. If you enter 257 or more characters, the name is automatically shortened to 256 characters.
<A1>= The first argument (or local variable) used in the subroutine. This variable generally cannot be accessed outside of the subroutine.
<A2>= Second argument used in the subroutine. This variable generally cannot be accessed outside of the subroutine. Additional arguments can be added as needed.
<Arg1> = The default value for the first argument.
<Arg2>= The default value for the second argument.
<Description> = The description for the argument.
<Commands> = Other Edit window commands can be inserted as needed after the arguments and before the ENDSUB command.
ENDSUB/ is the command used to end the subroutine command block.
Example Subroutine Command Block
For example, a finished subroutine that takes operator data and displays it to the report might look like this:
SUBROUTINE/GET_OPERATOR_INFO,
OPNAME = <Operator> : OPERATOR NAME, SHIFT = <Shift> : SHIFT TIME,
=
COMMENT/REPT,OPNAME
COMMENT/REPT,SHIFT
ENDSUB/