16
3 PROGRAM ORGANIZATION UNITS
3.2 Functions (FUN)
Labels defined by a function
The labels defined by a function are assigned in the temporary areas of the storage-target memory during execution of the
function, and the areas are freed after the processing completes.
When calling FUN1 and FUN2 from the main program, and calling FUN3 by FUN1
( to indicate the execution flow (order).)
The following figure shows the label assignments while the above functions are being executed.
The class of labels that can be defined in the function are VAR, VAR_CONSTANT, VAR_INPUT, and VAR_OUTPUT.
The label to be defined by a function must be initialized by a program before the first access because the label
value will be undefined.
FUN1
FUN2
FUN3
(Program file)
Main program
(FUN file)
FUN1 program
(FUN file)
FUN2 program
(FUN file)
FUN3 program
Label area of FUN3
Main program being executed FUN1 being executed
(before FUN3 is called)
FUN3 being executed
Label area of FUN1 Label area of FUN1 Label area of FUN1
FUN1 being executed
(after FUN3 is executed)
Main program being executed FUN2 being executed
Label area of FUN2
Main program being executed
Temporary area