Local Variables
The special Local Variables named Local1 through to Local5 are automatically declared within the script engine. You do not need to declare these yourself to use them.
They are declared as follows.
var
Local1 : Variant;
var
Local2 : Variant;
. . .
var
Local5 : Variant;
Local Variables are local to each event.
Therefore, if you have 2 fields that you are mapping, then 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 the field 2 OnMap, and 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 the 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 as below.
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, and 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.