LOCAL

Purpose:

Declares a variable local to a function.

Syntax:

LOCAL  var1, var2, ..., varN

varN

-

One or more variable names.

Example:

myfun(x)
{
    local j, fft;
 
    for (j = fft = 0, j < x, j++)
    {
        fft += j;
    }
 
    return(fft);
}

 

 

SPL recognizes j and fft as local variables. The symbol fft is treated as a local variable, not the FFT function.

Remarks:

An undeclared variable assigned in an SPL function is treated as a local variable.  Thus, the local keyword is not strictly necessary, but is extremely useful for eliminating a conflict between a local variable name and a function or macro. The keyword also provides optimization benefits as the type of variable is made explicit.

 

The value of an undeclared variable referenced in an SPL is first searched as a local variable. If not found, the variable is treated as a global variable.

 

See STATIC to define local variables that are persistent across SPL function calls.

 

See GLOBAL or EXTERN to define global variables in an SPL function.

 

See NONLOCAL to define a variable that can be private to one SPL function but accessible to another.

See Also:

EXTERN

GLOBAL

NONLOCAL

SETLOCALVARIABLE

SETVARIABLE

STATIC