Reference Manual

PMAC 2 Software Reference
PMAC Program Command Specification 319
GOSUB
Function
Unconditional Jump With Return
Type
Motion program (PROG only)
Syntax
GOSUB{data}
where:
{data} is a constant or expression representing the line label to jump to.
{letter} (optional) is any letter character except N or O.
Remarks
This command causes the motion program execution to jump to the line label (N or O) of
the same motion program specified in {data}, with a jump back to the commands
immediately following the GOSUB upon encountering the next RETURN command.
If {data} is a constant, the path to the subroutine will have been linked before program
run time, so the jump is very quick. If {data} is a variable expression, it must be
evaluated at run time, and the appropriate label then searched for.
The search starts downward in the program to the end, then continues (if necessary) from
the top of the program down.
A variable GOSUB command permits the equivalent structure to the CASE statement
found in many high-level languages.
If the specified line label is not found, the GOSUB command will be ignored, and the
program will continue as if the command had not occurred.
The CALL command is similar, except that it can jump to another motion program.
Example
GOSUB300 jumps to N300 of this program, to jump back on RETURN.
GOSUB8743 jumps to N8743 of this program, to jump back on RETURN.
GOSUB(P17) jumps to the line label of this program whose number matches the current
value of P17, to jump back on RETURN.
See Also
Writing a Motion Program
Program commands CALL, GOTO, N, O, RETURN
GOTO
Function
Unconditional Jump Without Return
Type
Motion program (PROG only)
Syntax
GOTO{data}
where:
{data} is an integer constant or expression with a value from 0 to 99,999.
Remarks
This command causes the motion program execution to jump to the line label (N or O)
specified in {data} with no jump back.
If {data} is a constant, the path to the label will have been linked before program run
time, so the jump is very quick. If {data} is a variable expression, it must be evaluated
at run time, and the appropriate label then searched for. The search starts downward in
the program to the end, then continues (if necessary) from the top of the program down.
A variable GOTO command permits the equivalent structure to the CASE statement found
in many high-level languages. (See Example, below.)