Variables and constants reserve storage in an EGL program. Constant values cannot change at run time.
You must explicitly declare all EGL variables. You can use variables without declaring them in some other languages, but not in EGL.
customerBalance DECIMAL(9,2);
myCustomer CustomerRecord;
myDictionary Dictionary
{
empnum=0005,
lastName="Twain",
firstName="Mark",
birthday="021460"
};
The notion of a type describes the way a particular variable or expression represents a value. Types also determine compatibility; for instance, you can add the character representation of a number to a string, and you can add a number to the integer code point representation of a character, but you cannot add a number to a character.
EGL has primitive data types like INT and CHAR that are simple and straightforward. The language also has more complex parts that also function as types. Additionally, EGL uses a few special characters as type extensions when you define variables, as described in the following table:
Character(s) | Example | Meaning |
---|---|---|
anInt INT; | Single instance of this type; if this is a value type (not a reference) variable, it is a named area of storage containing the data. | |
[] | anIntArray INT[]; | An array of this type; see Arrays. |
? | aNullableInt INT?; | A variable that can contain a null value; see Null values and the nullable type. |
customerBalance DECIMAL(9,2) = 1001.22;
After you declare a variable, you can assign a new value at any time through regular assignment syntax. For more on this subject, see Assignments. For information about using literals in assignments, see Literals.
const copyrStr String = "Copyright 2007 by CompanyB";
const myArray BIN[] = [36, 49, 64];
const myArray02 BIN[][] = [[1,2,3],[5,6,7]];
const myValue myDataitem;
dataitem myDataitem char(30) {value = "Manufactured by CompanyC"} end
You cannot include a constant in a record or other complex structure.
You can include the reserved word const as a modifier on function parameters. For more information, see Parameter modifiers.
const myString01, myString02 STRING = "INITIAL";
myVar01, myVar02, myVar03 CHAR(5);
myRecord01, myRecord02 ExampleRecord;