A set-values block is an area of code in which you can set property, field, or variable values. For background on properties, see "Overview of EGL properties."
In the last two cases, you can assign values only to fields.
program hello
myString STRING = "Hello, Cleveland";
{handleHardIOErrors = YES} // this works
...
end
program hello
myString STRING = "Hello, Cleveland"
{handleHardIOErrors = YES}; // this is part of myString declaration
...
end
The problem is that handleHardIOErrors is now in the scope of the string "Hello, Cleveland." A string has no fields to set, let alone a field named "handleHardIOErrors," so EGL cannot resolve the expression.
myInt INT?{};
myList Dictionary; // myList = null
myList.x = 23; // illegal reference
However, the
following code initializes a new dictionary variable before attempting
the assignment:myList2 Dictionary; // myList2 = null
myList2{ x = 23 }; // myList2 now has one key, x, whose value is 23
package com.companyb.customer;
Record StructuredRecordA
10 fullCheckNum NUM(25);
15 bankNum NUM(9);
15 acctNum NUM(10);
15 checkNum NUM(6);
end
program calculate type BasicProgram
function main()
myRec1 StructuredRecordA
{fullCheckNum = 9531008501602141091001484};
writeStdOut(myRec1.bankNum); // 953100850
writeStdErr(myRec1.checkNum); // 1484
end
end
myRec2 StructuredRecordA {checkNum = 1485};
writeStdOut(myRec2.fullCheckNum); // 1485
If you make multiple assignments to the same field or property in a set-value block, the last assignment takes effect. That rule also applies to fields of complex properties, which are described in "Set-values blocks in complex properties" in this topic.
In any case, the set-values block is in the scope of the part, variable, or field being modified. The variations in syntax are best illustrated by example.
// the scope is myVariable
myVariable INT
{
inputRequired = yes,
align = left
};
// scope is optionEntry
DataItem optionEntry INT
{
inputRequired = yes,
align = left
};
end
// scope is menu1Option
menu1Option optionEntry
{
inputRequired = no
};
myRecord02.myContent01 = "abc";
myRecord02.myContent02 = "xyz";
myRecord02
{
myContent01="abc",
myContent02="xyz"
};
The abbreviated assignment statement is not available for fields in a structured record, and you cannot use it to set properties.
When you are assigning values for a field within a record variable, narrow the scope to the specific field, as follows.
record myBasicRecord03 type basicRecord
myInt04 INT;
end
record myBasicRecord02 type basicRecord
myInt03 INT;
myRec03 myBasicRecord03;
end
record myBasicRecord type basicRecord
myInt01 INT;
myInt02 INT;
myRec02 myBasicRecord02;
end
The syntax for assigning a property value can take any of the forms shown in the following examples, which apply to the field myInt04:
// dotted syntax
myRecB myBasicRecord
{
myRec02.myRec03.myInt04{ align = left }
};
// bracket syntax
// You cannot use this syntax to affect
// fields in fixed structures
myRecC myBasicRecord
{
myRec02["myRec03"]["myInt04"]{ align = left }
};
// brace syntax
myRecA myBasicRecord
{
myRec02 {myRec03 { myInt04 { align = left }}}
};
// dotted syntax
myRecB myBasicRecord
{
myInt01 = 4,
myInt02 = 5,
myRec02.myRec03.myInt04{ align = left },
myRec02.myInt03 = 6
};
// bracket syntax
myRecC myBasicRecord
{
myInt01 = 4,
myInt02 = 5,
myRec02["myRec03"]["myInt04"]{ align = left },
myRec02["myInt03"] = 6
};
// brace syntax;
// but this usage is much harder to maintain
myRecA myBasicRecord
{
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) that has the same name as a record property. To refer to your field rather than to the property, use the keyword this, which establishes the scope as being the declaration in which the set-value block resides.
Record ExampleRecord type SQLRecord
{ tableNames = [["myTable"]],
keyItems = [myKey] }
myKey CHAR(10);
myOtherKey CHAR(10);
keyItems CHAR(60);
end
myRecord ExampleRecord
{
keyItems = [myOtherKey],
this.keyItems = "abc"
};
For an example in an array declaration, see "Additional set-values block examples."
myService ExampleServicePart
{ @xml
{name="myService",
namespace="http://www.customerpackage.companyb.commy.useful.service"}
};
Record Point
x INT;
y INT;
end
Record Rectangle
topLeft Point;
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};
The keyword this has a different meaning outside of a set-values block (see The "this" keyword). In any case, the use of pts[1] here is not ambiguous, so no such distinction is necessary.
points Point[];
points{x=1, y=1};
points[1]{x=10, y=20};
points{};
points.resize(2);
points{x=1, y=1};