You can insert this command by simply 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.

1. Select Insert | Flow Control Command | Subroutine from the submenu. This brings up the Subroutine Creation dialog box. For information on this dialog box, see the "Understanding the Subroutine Creation Dialog Box" topic.

Subroutine Creation dialog box

2. Give the subroutine a name by typing it the Name box.

3. If your subroutine uses arguments, place holders for information passed into the subroutine, add them one by one by clicking the Add Arg 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

4. Give your argument a name by typing it in the Name box.

5. 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.

6. If you want to give a description, type it in the Description box.

7. Click OK in the Argument Edit dialog box to create the argument.

8. Repeat steps 3 to 7 for each argument you want in your subroutine.

9. 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.

10. End your subroutine. Select 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 part program commands you want in your subroutine must be added inside the subroutine's command block, before the ENDSUB command.

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.

<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.

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/

### Creating a New Subroutine

Creating a Subroutine by Typing SUBROUTINE

Creating a Subroutine by Using the Subroutine Menu Item

Syntax for a Subroutine Command Block

Example Subroutine Command Block