Super Globals
Super Globals are global Variables that can be defined by the user. They are always of type Variant.
They are called Super Globals because they are global across the entire Statelake system. A Super Global can be referenced from any Map, or from a different execution of the same Map.
Super Globals are naturally persistent - they are persistent across the entire execution of Statelake. Therefore only when Statelake or StatelakeServer is restarted will the Super Globals be reset. However, because they are persistent across the entire Statelake system, extra care should be taken when using Super Globals so that you don't use the same global for different purposes. It would cause a conflict as to the value you expect to find within the Super Global at any one time.
Super Globals are referenced like fields through the special globals array. Their value can be accessed through the properties .Value, .AsString, .AsInteger, and .AsFloat.
Setting A Super Global
The following example creates and sets a Super Global called MyGlobal to the String value of Testing.
If the Super Global does not already exist, then it will be created and loaded with the value specified.
If the Super Global does exist, then it will be updated with the new value as specified.
procedure
ScriptEvent (
var
Value : variant);
begin
Globals[
'MyGlobal'
].AsString :=
'Testing'
;
end
;
Reading A Super Global
The following example reads the value of the Super Global called MyGlobal.
If the Super Global does not already exist, then it will return a null value depending on the accessor used. In this example .AsString is used, therefore it will return a blank string.
procedure
ScriptEvent (
var
Value : variant);
begin
Value := Globals[
'MyGlobal'
].AsString;
end
;
Reading A Super Global Using Tags
Super Globals can be accessed outside of scripts wherever Tags are supported.
To access a Super Global as a Tag, you should enter the name of the Super Global surrounded by the opening Tag <$ and closing Tag $>. For example, to access a Super Global called MyGlobal, you would enter the Tag <$MyGlobal$>.
Specifying A Display Format For .AsString And Tags
When accessing float and date/time type Super Globals with .AsString or through Tags, you can control the format of the resulting string value. For more information, please refer to the section on Format Specifiers.
The following example shows how to set the display format.
procedure
ScriptEvent (
var
Value : variant);
begin
Globals[
'MyGlobal'
].DisplayFormat :=
'yyyy-mm-dd'
;
Globals[
'MyGlobal'
].DisplayFormat :=
'#0.00'
;
end
;
Removing A Super Global
The example below shows how to delete the Super Global called MyGlobal.
If the Super Global does not exist then nothing will happen and you will not receive an error message.
procedure
ScriptEvent (
var
Value : variant);
begin
Globals
.
RemoveGlobal(
'MyGlobal'
);
end
;
Clear All Super Globals
The below example clears all Super Globals.
procedure
ScriptEvent (
var
Value : variant);
begin
Globals
.
ClearAllGlobals;
end
: