The DEFSUB Command [MLEPC]
The DEFSUB command can be used to define a subprogram that will later be called using the CALSUB command, or to define when subprograms should be output to the NC program, or to define the behavior of INDEX and COPY commands that are passed to the post-processor from the CAM system.
Subprogram Definition
The DEFSUB command is used to identify the beginning of the definition of a subprogram. A subprogram consists of: a DEFSUB command naming the subprogram; one or more part program instructions defining the body of the subprogram; and a terminating ENDSUB command. A subprogram is called by coding a CALSUB command with a matching subprogram identifier. This command is valid for all machine types.
The subprogram ID[1] can be identified by either a whole number value a, or by a quoted subprogram name.
Various subprogram types are supported:
CNC specifies a subprogram defined in a separate program element than the caller. The post-processor will output a subprogram containing the code generated from the DEFSUB-ENSUB block either immediately, or when called, or at the end of processing, depending on how the post-processor is configured. For each call, the post-processor will update the processing status based on the subprogram contents, and then will generate a call instruction to the subprogram.
RANGE specifies a subprogram defined as repeat range in the same program element as the caller. The post-processor will process the DEFSUB-ENDSUB contents at the first call, bounded by labels or sequence numbers. For each subsequent call, the post-processor will update the processing status based on the subprogram contents, and then will generate a call instruction to repeat the bounded code.
INCLUD specifies an emulated subprogram. The post-processor will save the contents of the subprogram, and then will post-process the saved CLDATA contents at each call.
CLDATA specifies to use preferably a CNC subprogram if supported, but if not then a RANGE repeat if supported, otherwise to emulate the subprogram (i.e., INCLUD).
SYSTEM specifies a controller resident subprogram. For each call, the post-processor will update the processing status based on the subprogram contents, and generate a call instruction to the controller resident subprogram. The subprogram itself is not output.
The couplet OPTION,b (keyword,
A maximum of 500 subprograms can be defined in a program.
Subprogram Output
The following DEFSUB command forces immediate output of deferred subprogram definitions to the tape file (non deferred subprograms are not affected by this command).
Normally, deferred subprograms are output at the end of the program. This command can be used to fine tune the placement of subprograms. Once the NOW keyword is coded, subsequent subprogram definitions will cause an error.
Index and Copy Behavior
The following DEFSUB command defines the behavior of INDEX and COPY commands that are passed to the post-processor from the CAM system.
TYPE,
TRFORM,