From Clomosy Docs
Global variables are variables that are defined and can be used in any part of a program. These variables are typically defined in the main part of the program, which is accessible to all functions and procedures. Global variables are often used to store the state of the program or general settings.
The Clomosy platform provides functions for defining global variables. These functions are designed to store values that will be commonly used across different units.
For example, if a string variable defined on the Main Code page needs to be sent to the next page (Unit) and used there, it can be defined using these functions.
In Clomosy, there are different types of global variable usages. These predefined global definitions can facilitate data transfer between pages based on the type of data.
-
It is the function used to store data of the string data type.
-
It is the function used to store data of the integer data type.
- It is the function used to store data of the TclDateTime data type.
-
It is the function used to store and keep an array of the TclStringList data type.
GlobalVariableString
function Clomosy.GlobalVariableString: String;
It is the function used to store data of the string data type.
To assign data to a variable:
Clomosy.GlobalVariableString = 'Test';
To retrieve data assigned to a global variable:
ShowMessage(Clomosy.GlobalVariableString);
Example
var
userName : String;
{
userName = 'XName';
Clomosy.GlobalVariableString = userName;
ShowMessage(Clomosy.GlobalVariableString);
}
GlobalVariableInteger
function Clomosy.GlobalVariableInteger: String;
It is the function used to store data of the integer data type.
To assign data to a variable:
Clomosy.GlobalVariableInteger = 28;
To retrieve data assigned to a global variable:
ShowMessage(Clomosy.GlobalVariableInteger);
Example
var
userId : Integer;
{
userId = 11;
Clomosy.GlobalVariableInteger = userId;
ShowMessage(Clomosy.GlobalVariableInteger);
}
GlobalVariableDateTime
function Clomosy.GlobalVariableDateTime: TclDateTime;
It is the function used to store data of the TclDateTime data type.
To assign data to a variable:
Clomosy.GlobalVariableDateTime = 28.01.2024 00:19:43;
To retrieve data assigned to a global variable:
ShowMessage(Clomosy.GlobalVariableDateTime);
Example
var
dateTime : TclDateTime;
{
dateTime = Now;
Clomosy.GlobalVariableDateTime = dateTime;
ShowMessage(Clomosy.GlobalVariableDateTime);
}
GlobalVariableStringList
function Clomosy.GlobalVariableStringList: TclStringList;
It is the function used to store and keep an array of the TclStringList data type.
Example
var
productList,incomingProductList: TclStringList;
i: Integer;
{
productList = Clomosy.StringListNew;
productList.Add('Product 1');
productList.Add('Product 2');
productList.Add('Product 3');
Clomosy.GlobalVariableStringList = productList;
//The retrieved string list should be assigned to another list and displayed on the screen.
incomingProductList = Clomosy.StringListNew;
incomingProductList = Clomosy.GlobalVariableStringList;
for (i = 0 to incomingProductList.count - 1)
ShowMessage(Clomosy.StringListItemString(incomingProductList,i));
}