Skip to content

Flow documentation · legacy product

LOCAL Variables ​

The special LOCAL variables (LOCAL1 > LOCAL5) are automatically declared within the script engine. You do not need to declare these yourself to use them. They are declared as

pascal
var LOCAL1 : Variant;
var LOCAL2 : Variant;
...
var LOCAL5 : Variant;

The LOCAL variables are local to each event. Therefore if you have 2 fields you are mapping each of their OnMap events will contain a separate set of LOCAL variables. If you set LOCAL1 to a value in field 1 OnMap, you will not be able to read that value through LOCAL1 in field 2 OnMap. You will also not be able to read it from field 1 BeforeMap.

LOCAL variables are also Persistent. This means that it will retain its value between each execution of the script in which it is used. If in the first execution of field 1 OnMap you set the value to 10, it will retain this value the next time the field 1 OnMap script executes. This script will execute once for each record that is processed by the map.

An example of using LOCAL variables is

pascal
procedure ScriptEvent (var Value : variant);
begin
if LOCAL1 = null then LOCAL1 := 0;
LOCAL1 := LOCAL1 + 1;
LogInfo('Do something here');
end;

The above example uses LOCAL1 to implement a counter. It will count how many times this event has been executed. The first line initialises the LOCAL1 variable to 0 - this is necessary and will only fire the first time the script is executed. The second line increments the value of LOCAL1 by 1 each time the event executes.