13.PROGRAM CONFIGURATION
PROGRAMMING
B-63944EN/03
- 348 -
- Using a subprogram only
A subprogram can be executed just like a main program by searching
for the start of the subprogram with the MDI.
(See III-10.4 for information about search operation.)
In this case, if a block containing M99 is executed, control returns to
the start of the subprogram for repeated execution. If a block
containing M99Pn is executed, control returns to the block with
sequence number n in the subprogram for repeated execution. To
terminate this program, a block containing /M02 ; or /M30 ; must be
placed at an appropriate location, and the optional block switch must
be set to off ; this switch is to be set to on first.
N1010 . . . ;
N1020 . . . ;
N1030 . . . ;
N1040 . . . M02 ;
N1050 M99 P1020 ;
/
Optional block skip ON
- Subprogram call with sequence number
Setting bit 0 (SQC) of parameter No. 6005 to 1 can call a specified
sequence number in the subprogram for execution.
In a subprogram call command, specify the letter Q followed by a
sequence number to be called after the letter P for specifying a
program number.
M98 Pxxxx Qxxxxx ;
Sequence
number
Program
number
This command causes program execution to start at the called
sequence number in the subprogram. If a repetition count is
specified, program execution is repeated from the specified sequence
number.
Main program
N0010
…
;
N0020
…
;
N0030 M98 P1010 Q1030 ;
N0040
…
;
N0050
…
;
N0060
…
;
Sub program
O1010
…
;
N1020
…
;
N1030
…
;
N1040
…
;
N1050
…
;
N1060
…
M99 ;
This function enables a sequence number in the same program to be
called for execution as shown below.
This method, however, requests the programmer to be aware of an
allowable call nesting level. If an attempt is made to exceed the
allowable nesting level, alarm PS0077 meaning “TOO MANY
SUB,MACRO NESTING” is issued.