
8
SUB to END SUB 8-213
8
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
125
SUB to END SUB
Defines a sub-procedure
Format
SUB label (dummy argument, dummy argument...)
command block
END SUB
Explanation
Defines a sub-procedure.
The sub-procedure can be executed by a CALL statement. When the END SUB
statement is executed, the program jumps to the next command after the CALL
statement that was called. Definitions are as follows.
1. All variables declared within the sub-procedure are local variables, and these are
valid only within the sub-procedure. Local variables are initialized each time the
sub-procedure is called up.
2. Use a SHARED statement in order to use global variables (program level).
3. Use a <
dummy argument
> when variables are to be passed on. If two or more
dummy arguments are used, separate them by a comma ( , ).
4. A valid <
dummy argument
> consists of a name of variable and an entire array
(array name followed by parentheses). An error will occur if array elements (a
<
subscript
> following the array name) are specified.
• Sub-procedures cannot be defined within a sub-procedure.
• A label can be defined within a sub-procedure, but it cannot jump (by a GOTO or GOSUB
statement) to a label outside the sub-procedure.
• Local variables cannot be used with PRINT and SEND statements.
SAMPLE 1
A=1
CALL *TEST
PRINT A
HALT
’SUB ROUTINE: TEST
SUB *TEST
A=50 ····················· Handled as a different variable than
the "A" shown above.
END SUB
• In the above example, the program level variable "A" is unrelated to the variable "A" within the
sub-procedure. Therefore, the value indicated in the 3rd line PRINT statement becomes "1".
MEMO
MEMO
Summary of Contents for SCARA YRCX Series
Page 1: ... 7 6HULHV DW 1R 1 5 5RERW RQWUROOHU 352 5 00 1 0 18 6 5 5RERWV 5 6HULHV ...
Page 2: ......
Page 20: ......
Page 26: ......
Page 27: ...Chapter 2 Constants 1 1 Outline 2 1 2 2 Numeric constants 2 1 3 3 Character constants 2 2 ...
Page 28: ......
Page 32: ......
Page 52: ......
Page 54: ......
Page 61: ...Chapter 5 Multiple Robot Control 1 1 Overview 5 1 2 2 Command list with a robot setting 5 2 ...
Page 62: ......
Page 66: ......
Page 76: ......
Page 78: ......
Page 92: ......
Page 328: ......
Page 408: ......
Page 409: ...Chapter 11 User program examples 1 1 Basic operation 11 1 2 2 Application 11 8 ...
Page 410: ......
Page 432: ......
Page 488: ......
Page 489: ...Chapter 13 Appendix 1 1 Reserved word list 13 1 2 2 Changes from conventional models 13 3 ...
Page 490: ......
Page 496: ......
Page 497: ...Index ...
Page 498: ......
Page 504: ......
Page 505: ......
Page 506: ... DW 1R 1 XWKRUL HG LVWULEXWRU 3ULQWHG LQ XURSH ...