Skip to content

Flow documentation · legacy product

Local Globals ​

Local Globals are global variables that can be defined by the user but are limited in scope to a single execution of an Action. They are always of type Variant.

They are local globals because they are global only within a single execution of an Action. A local global can be referenced from any object so long as it is executing within the same Action.

Local Globals are not Persistent. They are persistent across the entire execution of an Action, but are reset for each new execution of the same Action.

Care should be taken when using local globals that you don't use the same local global for different purposes within the same Action. It would cause a conflict as to the value you expect within the local global at any one time.

Local Globals are referenced like fields through the special Locals array. Their value can be accessed through the properties .Value, .AsString, .AsInteger, and .AsFloat (Refer to Referencing Fields for information on how these properties work with fields - it is the same for local globals).

Setting a local global
pascal
procedure ScriptEvent (var Value : variant);
begin
Locals['MyLocalGlobal'].AsString := 'abc';
end;

This example sets a local global called MyLocalGlobal to 'abc'. If the local global does not already exist it will be created. If it does exist it will be updated with the new value.

Reading a local global
pascal
procedure ScriptEvent (var Value : variant);
begin
Value := Locals['MyLocalGlobal'].AsString;
end;

This example reads the value of the local global called MyLocalGlobal. If the local global does not already exist it will return a null value (depending on the accessor used - in this case .AsString is used therefore it will return a blank string)

Reading a local global using Tags

Local Globals can be accessed outside of scripts where ever Tags are supported. To access a local global as a tag you should entered the local global's name surrounded by the opening tag <# and closing tag #>. For example to access a local global called MyLocalGlobal you would enter the tag <#MyLocalGlobal#>

Specifying a display format for AsString and Tags
pascal
procedure ScriptEvent (var Value : variant);
begin
Locals['MyLocalGlobal'].DisplayFormat := 'yyyy-mm-dd';
Locals['MyLocalGlobal'].DisplayFormat := '#0.00';
end;

When accessing Float and Datetime type Local Globals with AsString or through Tags, you can control the format of the resulting string value. The above example shows how to set the Display Format. See Number Format Specifiers and Date Format Specifiers for appropriate format specifiers.

Removing a local global
pascal
procedure ScriptEvent (var Value : variant);
begin
Locals.RemoveLocal('MyLocalGlobal');
end;

This example deletes the local global called MyLocalGlobal. If the local global does not exist nothing will happen - you will not receive an error message.

Clear all local globals
pascal
procedure ScriptEvent (var Value : variant);
begin
Value := Locals.ClearAllLocals
end;

This example deletes all local globals.