Branching with Subroutines

Subroutines are blocks of code in your measurement routine or in an external measurement routine 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.

Subroutine command blocks are enclosed within SUBROUTINE and ENDSUB commands.

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

Subroutines are called by using the CALLSUB command.

External Subroutines

External subroutines, or subroutines located in a measurement routine outside of the calling measurement routine, do not have access to features, variables, or alignments from the calling measurement routine. The subroutine would still have access to items within its own measurement routine. The external measurement routine and the calling measurement routine 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