A set-value block is an area of code in which you can set both property and field values. For background, see Overview of EGL properties.
In the last two cases, you can assign values only to fields.
In all cases, the set-value block is in the scope of the part, variable, or field being modified. The variations in syntax are best illustrated by example.
// the scope of the set-value block is myPart DataItem myPart INT { inputRequired = yes, align = left } end
// the scope is myVariable myVariable INT { inputRequired = yes, align = left };
// The scope is myRecordPart Record myRecordPart type SQLRecord { tableNames = [["myTable"]], keyItems = ["myKey"] } myKey CHAR(10); myOtherKey CHAR(10); myContent01 CHAR(60); myContent02 CHAR(60); end
// The scope is myRecord myRecord myRecordPart { keyItems = ["myOtherKey"], myContent01 = "abc", myContent02 = "xyz" };
// the example shows the only case in which a // record property can be overridden in a // variable declaration. // the scope is myRecord myRecord myRecordPart {keyItems = ["myOtherKey"]}; // the scope is myInteger, which is an array myInteger INT[5] {1,2,3,4,5}; // these assignment statements // have no set-value blocks myRecord02.myContent01 = "abc"; myRecord02.myContent02 = "xyz"; // this abbreviated assignment statement // is equivalent to the previous two, and // the scope is myRecord02 myRecord02 { myContent01="abc", myContent02="xyz" }; // This abbreviated assignment statement // resets the first four elements of the array // declared earlier myInteger{6,7,8,9};
The abbreviated assignment statement is not available for fields in a fixed structure.
When you are assigning values for a field of a field, you use a syntax in which the set-value block is in a scope such that the entries are modifying only the field of interest.
record myBasicRecPart03 type basicRecord myInt04 INT; end record myBasicRecPart02 type basicRecord myInt03 INT; myRec03 myBasicRecPart03; end record myBasicRecPart type basicRecord myInt01 INT; myInt02 INT; myRec02 myBasicRecPart02; end
The syntax for assigning a property value may take any of three forms, as shown in the following examples, which apply to the field myInt04:
// dotted syntax, as described in // References to variables in EGL. myRecB myBasicRecPart { myRec02.myRec03.myInt04{ align = left } }; // bracket syntax, as described in // Bracket syntax for dynamic access. // You cannot use this syntax to affect // fields in fixed structures. myRecC myBasicRecPart { myRec02["myRec03"]["myInt04"]{ align = left } }; // curly-brace syntax myRecA myBasicRecPart { myRec02 {myRec03 { myInt04 { align = left }}} };
// dotted syntax myRecB myBasicRecPart { myInt01 = 4, myInt02 = 5, myRec02.myRec03.myInt04{ align = left }, myRec02.myInt03 = 6 }; // bracket syntax myRecC myBasicRecPart { myInt01 = 4, myInt02 = 5, myRec02["myRec03"]["myInt04"]{ align = left }, myRec02["myInt03"] = 6 }; // curly-brace syntax; // but this usage is much harder to maintain myRecA myBasicRecPart { myInt01 = 4, myInt02 = 5, myRec02 { myRec03 { myInt04 { action = label5 }}, myInt03 = 6 } };
In a variable declaration or assignment statement, you can have a container (such as an SQL record) that includes a field (such as keyItems) which is named the same as a record property. To refer to your field rather than to the property, use the keyword this, which establishes the correct scope for the set-value block or for an entry in the set-value block.
Record myRecordPart type SQLRecord { tableNames = [["myTable"]], keyItems = ["myKey"] } myKey CHAR(10); myOtherKey CHAR(10); keyItems CHAR(60); end
myRecord myRecordPart { keyItems = ["myOtherKey"], this.keyItems = "abc" };
The next section gives an additional example in an array declaration.
col1 ConsoleField[5];
col1 ConsoleField[5] { position = [1,1], color = red };
// assign values to the second and fourth element col1 ConsoleField[5] { this[2] { color = blue }, this[4] { color = blue } };
For details on another use of the keyword this, see Scoping rules and "this" in EGL.
new Menu { labelText = "Universe", MenuItems = // property value is a dynamic array [ new MenuItem { name = "Expand", labelText = "Expand" }, new MenuItem { name = "Collapse", labelText = "Collapse" } ] }
To review a syntax that is an extension of what has gone before, consider the complex property @ProgramLinkData. That property includes the property fields programName and linkParms; and linkParms takes an array of property fields, each of complex property @LinkParameter.
DataItem Prog1LinkItem char(9) { @ProgramLinkData { programName = “my.company.sys1.PROG1”, linkParms = [ @LinkParameter {name=“parm1”, value=”abc”}, @LinkParameter {name=”parm2”,value=”efg”} ] } } end
DataItem Prog1LinkItem char(9) { @ProgramLinkData { programName = “my.company.sys1.PROG1”, linkParms = [ @LinkParameter {name=“parm1”, value=”abc”}, @LinkParameter {name=”parm2”,value=”efg”} ] }, displayName = “Go to Program02” } end
Record Point x, y INT; end Record Rectangle topLeft, bottomRight Point; end
Function test() screen Rectangle { topLeft{x=1, y=1}, bottomRight{x=80, y=24} }; // change x, y in code, using a statement // that is equivalent to the following code: // screen.topLeft.x = 1; // screen.topLeft.y = 2; screen.topLeft{x=1, y=2}; end
pts Point[2] { this[1]{x=1, y=2}, this[2]{x=2, y=3} };
pts{ x=1, y=1 }; pts[1]{x=10, y=20};
In the previous example, pts[1] is used rather than this[1] because the array name is unambiguous.
points Point[];
points{x=1, y=1};
points[1]{x=10, y=20};
points.resize(2); points{x=1, y=1};
Related concepts
Bracket syntax for dynamic access
Overview of EGL properties
References to variables in EGL
Scoping rules and "this" in EGL
Related reference
Arrays
Data initialization
openUI