LOCAL


A new LOCAL statement allows fields to be declared to be LOCAL to the current context.

LOCAL saves the named field's value. When the current context completes, it restores the saved value before returning to the invoking context.

LOCAL works in subroutines called via a GOSUB, and in Start of Process event points.

Description:

A LOCAL statement is (nearly) equivalent to a RECEIVE statement that executes without a matching PASS statement (such a RECEIVE statement will set the next T/F to F, but a LOCAL statement doesn't change the T/F flags).

When you execute a LOCAL (or RECEIVE) statement, the engine decides the point in time that the original value should be restored according to the following rules:

1) If you execute a LOCAL (or RECEIVE) while there is a GOSUB active (in the current event point), the original value is restored when you execute a RETURN statement.

2) If there is no GOSUB active, the original value is restored when the event point ends (with one exception described in the next rule).  That means that you can add LOCAL statements to the beginning of an event point to protect variables that you want to use in that event point.

3) If you execute a LOCAL statement (and there is no active GOSUB) in the Start of Process event point, you are protecting a variable for the life of the process (the original value is restored when the process ends).