![Okuma OSP-P200L Programming Manual Download Page 288](http://html1.mh-extra.com/html/okuma/osp-p200l/osp-p200l_programming-manual_3667818288.webp)
5238-E P-275
SECTION 12 USER TASK
•
When using local variables in a called subprogram, and there are several local variables with
the same name registered in the memory, the data of the local variable which last had that
name registered is used. The local variables set in the block containing the CALL statement
are all cleared when the RTS statement in the called subprogram is executed.
LE33013R0301400120003
In the example above, execution of N2010 in subprogram 2 registers 4 kinds of local variables
with the same name - ABC and DEF - then subprogram O3000 is executed. If subprogram
O3000 contains local variable names ABC and DEF, the numeric data registered last, i.e., ABC
= 400 and DEF = 350 are called for. At the end of subprogram O3000, that is, when the RTS
statement in 03000 is executed, the local variables registered by the subprogram CALL O3000,
ABC = 400 and DEF = 350, are cleared from the memory.
O1000
Main Program
Subprogram 1
Subprogram 2
Subprogram 3
ABC
DEF
ABC
DEF
ABC
DEF
ABC
DEF
20
50
100
150
500
750
400
350
Subprogram 1
O2000
Subprogram 2
O3000
Subprogram 3
Main Program
Registration of Local Variables
ABC=20 DEF=50
N100 CALL O1000
&ABC=100 DEF=150
N101
N1050 CALL O2000
&ABC=500 DEF=750
N1051
N1100 RTS
N2010 CALL O3000
&ABC=400 DEF=350
N2011
RTS
RTS
2
3
1
Cleared in
Cleared in
Cleared in
1
2
3