![Okuma OSP-P200L Programming Manual Download Page 289](http://html1.mh-extra.com/html/okuma/osp-p200l/osp-p200l_programming-manual_3667818289.webp)
5238-E P-276
SECTION 12 USER TASK
•
When a local variable is newly set in a subprogram, its name and numerical data are registered
in the memory. They are effective only in the subprogram in which they are set, and are cleared
when the RTS statement in that subprogram is executed.
LE33013R0301400120004
•
When numerical data is assigned to a local variable name which has already been assigned
other numerical data during execution of a subprogram, the numerical data is updated. If
several local variables with the same name are registered in the memory, the numerical data of
the local variable registered last is updated.
LE33013R0301400120005
When N2010 in subprogram 2 is executed, local variables ABC = 400 and DEF = 350 are
registered in the memory but they are cleared by executing RTS in subprogram 2. Therefore, in
blocks prior to N2040, the variables registered when subprogram 2 was called are used. When
block N2040 is executed, the numerical values of local variables ABC and DEF registered in
subprogram 2 are updated to 220 and 300, respectively, and those registered in subprogram 1
and the main program are not updated.
Main Program
Subprogram
N100 CALL O1000
O1000
N1100 RTS
Local variables set within these
blocks are all cleared when
block N1100 is executed.
Registration of Local Variables
Subprogram 2
Main Program
Subprogram 1
Subprogram 2
ABC 20
DEF 50
ABC 100
DEF 150
ABC 500
DEF 750
220
300
O2000
N2010 CALL O3000
&ABC = 400 DEF = 350
N2040 ABC = 220 DEF = 300
N2100 RTS