Local
Mon 01 January 2018Syntax
Local data_type &var_name [= expression]
Description
Use the Local statement to explicitly define local variables in PeopleCode.
Variable declarations can appear at the start of the program, intermixed with function declarations. Local variable declarations can also appear in the body of a program, including inside functions or methods.
The scope of local variables declared outside of a function or method is the PeopleCode program. The scope of local variables declared inside a function or method is to the end of the function or method. Also, these function local variables are different variables for each invocation of the function (even for recursive calls,) in the same manner as parameters.
Local variable declarations intermixed with the body of the program or inside functions or method can include initialization, that is, the variable can be set to a value at the same time it is declared.
In the absence of an initialization, the system automatically initializes temporary variables. Declared variables always have values appropriate to their declared type. Undeclared local variables are initialized as null strings.
Parameters
Field or Control |
Definition |
---|---|
data_type |
Any PeopleCode data type. |
& var_name |
A legal variable name. |
expression |
Specify the value of the variable. This parameter is optional. |