## Branching with Subroutines

Subroutines are blocks of code in your part program or in an external part program that are usually referenced repeatedly, allowing for more concise programming. PC-DMIS allows you to pass information to "arguments" (or local variables) in the subroutine. The types of arguments that can be passed into a subroutine are numeric values, variables, text strings, and feature names.

Hint: Subroutine command blocks are enclosed within SUBROUTINE and ENDSUB commands.

Once you have created a subroutine in your part program you can "call" it from your current part program or from another part program, causing the part program execution flow to go into the specified subroutine, executing commands contained within the subroutine command block. Program flow will then return to the statement immediately following the calling statement.

Hint: Subroutines are called by using the CALLSUB command.

External Subroutines

External subroutines, or subroutines located in a part program outside of the calling part program, do not have access to features, variables, or alignments from the calling program. The subroutine would still have access to items within its own part program. The external part program and the calling part program must use the same units of measurement.

Nesting Subroutines

You can nest subroutines within other subroutines. The only limitation to the number of arguments and nested subroutines is the amount of available memory.

More:

Creating a New Subroutine

Editing an Existing Subroutine

Understanding the Argument Edit Dialog Box

Calling a Subroutine

Subroutine Examples