The special Global Datasets such as Data1, Data2, etc, are automatically declared within the script engine for Maps, but not for custom scripts. You do not need to declare these yourself to use them.

The Global Datasets are of the TFloClientDataSet class - refer to this class for more information on what they can be used for at In-memory Dataset Class (TFloClientDataset).

They are pre-declared as:

var Data1 : TFloClientDataSet;
var Data2 : TFloClientDataSet;
. . .
var Data35 : TFloClientDataSet;
. . .

The Global Datasets are populated with data by the user calling database functions. Once populated with data, you can access its fields like any other dataset e.g. Data1['FieldName'].Value. Refer to Scripting Reference for more information about referencing fields.

The Global Datasets are global to each execution of a Map, but they are not shared between Maps - or even between different executions of the same Map.

Each Map contains its own set of Global Datasets. Therefore, if you have two Maps, and within one you populate Data1, you will not be able to access this dataset through Data1 in the second Map. Although, since a Global Dataset is global to the Map, you can populate it in one event and reference it from another. Therefore if within field 1 OnMap you populate Data1, you can read this dataset from field 2 OnMap.

Global Datasets are naturally persistent. This means that they will remain populated with data for the entire execution of the Map, or until you close it, or repopulate it. However, the next execution of the Map will have its own set of Global Datasets that start unpopulated.

An example of using Global Datasets follows. In this example, the Data1 dataset is populated with data by performing a bespoke SQL call through the source Data Definition. A check is made to determine whether any data was returned (Data1.EOF is True if no data is found), and then the values of the returned fields are used.

procedure ScriptEvent (var Value : variant);
begin
GetDataSetFromSource(Data1,'select accno, name from accounts where accno=10',0);
if Data1.EOF then
LogError('Unable to find account with account number 10')
else
Value := Data1['accno'].Value;
end;

Another simpler example is illustrated below.

procedure ScriptEvent (var Value : variant);
begin
Value := Data1['name'].AsString;
end;

This second script example is using the name field from the Data1 dataset that was populated in the first example.

To close or reset a Global Dataset within a Map, use the code Data1.Active := False;

Global Dataset Aliases

To provide dataset names that are more helpful than Data1, Data2, etc, many of the numbered Global Datasets also have a purpose-oriented alias.

For example, Data6 has the alias DATA_Company, and Data11 has the alias DATA_Product.

These are aliases for the same underlying dataset object, therefore an update to DATA_Company is also an update to Data6, and vice versa.