If you use a cell reference as a source in a formula, you must specify the data type of the value in the cell (string, integer, float, boolean) if either the column or table identifier is a variable or expression. That is, if the ESL compiler cannot determine the column that is being referenced for example, if your program should loop across all columns in a table then you must tell it how to treat the value from the cell. To do this, you simply specify the type immediately before the cell reference. If necessary, ESL may convert the contents of a cell at runtime to the type you told it to expect.
The following rules indicate the conditions under which you should use explicit data types in cell references:
1. If both the column and table identifiers are constants, do not specify an explicit data type.
When the column identifier is a column name, a constant string, or an integer constant and the table identifier is a name or a constant string, then the specific column is known; for example:
cell column EmpName of row 1 of EmpTable
In cases like this, do not use an explicit type or you will receive a compiler error. For example, the following generates a compiler error because the type of EmpName is already known:
integer cell column EmpName of row 1 of
EmpTable
Note that if you use a constant column name and a constant table name in a cell reference, but the column is not defined in that table, then ESL generates a warning because it is as if you had used a variable for the column name.
2. If the column identifier is a variable or an expression, you must specify an explicit data type.
This applies whether the table name is a constant or a variable, since ESL cannot determine the column being referenced until runtime (the column could be created dynamically). Therefore, you must tell the compiler what data type to expect; for example:
integer cell column VarColumn of row 1
of EmpTable
integer cell column VarColumn of row 1
of VarTable
If you omitted the explicit type in these cases, it would cause an error, since the contents of the variable VarColumn (and thus the type of this reference) is not known until runtime.
3. If the table identifier is a variable, you must specify an explicit data type if the column name is used for different type columns in separate tables.
When the table name is a variable or an expression, the data type of the column specified may or may not be clear. This includes response statements when cell references use the object built-in function.
In this case, ESL checks for columns with the given name in all statically defined tables. If there are multiple occurrences of this column name and they have different data types, then ESL cannot make any assumptions about the proper type. Thus, you must specify the data type in the cell reference.
For example, assume that columns named "Created" occur in more than one table, and that one of these columns is type integer and another is type string. To avoid a compiler error, a cell reference would have to appear as follows:
string cell column Created of row LoopVar
of object
4. If the table identifier is a variable and the column identifier is a constant and exists in only one table, or the column's data type is the same in all tables, the data type is optional. ESL allows you to omit the data type for a column if the column identifier is a constant (the table name can be a variable or an expression) and either of the following are true:
There is only one statically defined column with that name in any table.
There is a column with that name in multiple tables and they all have the same data type.
Typically, if the same name is used for columns in more than one table, it probably will be used to denote similar things. Therefore, ESL can assume that the type of the columns is the correct one to use for the cell reference. However, it does allow you to specify an explicit type because it may be safer for very large applications that contain many different tables created by different developers. Specifying the data type helps to ensure that future changes in the definition of one table will not cause compiler errors in another part of the program.
If you do choose to specify the data type of the cell reference in this case, be sure that the type you specify is the same as the type of the defined column(s).
Therefore, for example, if columns named "Sales" occur in more than one table, and all of these columns are of the type float, then both of the following references are valid:
cell column Sales of row TheRow of object
float cell column Sales of row TheRow of object