Using Local Variables

When you create library procedures that can be used in many programs, make them local. Then, if a program has a variable with the same name as a variable that is used in the procedure, a collision will not occur. SQR treats the two variables as separate.

Declare a procedure as local even if it does not take any arguments. To do this, place the LOCAL keyword following the procedure name in the BEGIN-PROCEDURE command.

To reference a global variable from a local procedure, insert an underscore between the prefix character (#, $, or &) and the variable name. Use the same technique to reference reserved variables , such as #current-line. These variables are always global so that you can reference them from a local procedure.

SQR supports recursive procedure calls, but it maintains only one copy of a local variable. A procedure does not allocate new instances of the local variables on a stack, as C or Pascal would.