Record primitiveRec type BasicRecord
integerField INT;
stringField STRING;
charField CHAR(30);
end
Creating a variable based on this Record part is similar
to creating a variable based on a DataItem part or primitive:myRecVar primitiveRec;
myRecVar.integerField = 6;
myRecVar.stringField = "Hello";
myRecVar.charField = "Character field";
myFunction(myRecVar);
Record myCustomerRecord type BasicRecord
customerNumber INT;
customerFirstName STRING;
customerLastName STRING;
customerBalance FLOAT;
end
The BasicRecord stereotype denotes a general-purpose Record part. You can use this stereotype when you want to group one or more variables together for simplicity.
Record myCustomerRecordSQL type SQLRecord
{ tableNames = [["Customer"]], keyItems = [customerNumber] }
customerNumber int {column = "CustomerID"};
customerFirstName string {column = "FirstName"};
customerLastName string {column = "LastName"};
end
In this case, the record is linked to a database table
named Customer that has columns named CustomerID, FirstName,
and LastName. When you link a record to a database
table like this, EGL can use this information to access the database
based on your interactions with the record. In simple terms, you can
use the record as though it were the row in the database.myRecordVar myCustomerRecordSQL;
myRecordVar.customerNumber = 5;
get myRecordVar;
SysLib.writeStderr("Name: " +
myRecordVar.customerFirstName + " " +
myRecordVar.customerLastName);
Other stereotypes that you can add to Record parts include IndexedRecord, SerialRecord, RelativeRecord, and CSVRecord, which are used for accessing different types of files.
Record parts can be structured to provide more detail about the layout and organization of their fields. In a structured record, each field is assigned a level number, an arbitrary number that indicates the relationship of that field to other fields.
record structRec1 type BasicRecord
10 field1 int;
10 field2 int;
10 field3 int;
end
Record CustomerRecord type BasicRecord
10 phoneNumber CHAR(10);
20 areaCode CHAR(3);
20 localNumber CHAR(7);
end
In this case, the fields areaCode and localNumber are
subfields of the field phoneNumber. You can access
the phoneNumber field to get the entire value of
the field, or you can access the areaCode or localNumber fields
to get a portion of the value held in the phoneNumber field.Structured records are limited to fields with fixed lengths. For more information on the limitations and uses of structured record, see Records.