GROUP-ENDGROUP
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
[access] GROUP name, [[dimension, ...]][type][size] [,X] member_def . . . ENDGROUP
The brackets around dimension are required if more than one dimension argument is specified. |
Arguments
access
(optional) One of the following access modifiers for a group within a class:
Access is not restricted. This is the most accessible option.
Access is limited to the containing class or types derived from the containing class.
Access is limited to the containing type. This is the least accessible option. (default)
Access is limited to the current assembly. (Synergy .NET only)
Access is limited to the current assembly and types derived from the containing class. (Synergy .NET only)
name
The name of the group to define.
dimension
(optional) A dimension of the group, which implies that the group is an array. If you specify more than one dimension, they must be enclosed in square brackets and separated by commas.
type
(optional) The data type of name which must be one of the following:
a = Alpha (default)
d = Decimal or implied-decimal
i = Integer
size
(optional) The maximum total size of all elements in the group. If type is implied-decimal, size has the form size.places, where size is the size of the entire field and places is the number of digits to the right of the decimal point. Size cannot be greater than 28. Places cannot be greater than 28 or greater than the value of size.
,X
(optional) Indicates that you’re defining an overlay for the last nonoverlay field or group.
member_def
Either the definition of a field within the group or another group declaration. Each field definition has the syntax described in Defining a field. You can specify as many member definitions as you want, although you must specify at least one.
Discussion
The GROUP statement defines a data structure within a record or another group structure. The ENDGROUP statement indicates the end of a group declaration.
You can only specify access modifiers (PUBLIC, PROTECTED, or PRIVATE) on a group within a class.
A group name must be unique among all other field and group names within a parent group. If a group isn’t part of another group, its name must be unique within the record. For example, the following group declaration is not valid, because group xyz and field xyz have the same name:
record abc xyz ,a5 group xyz ,a ijk ,a10 lmn ,a4 endgroup
The following declaration is also invalid, because two groups in the same record with the same immediate parent have the same name.
record fred group joe ,[12]a ed ,d5 leroy ,a2 endgroup group joe ,d bruno ,d12 al ,d4 endgroup
However, the example in Examples is valid, even though it declares two groups called address, because the two address groups don’t belong to the same parent group. The first address belongs to the office group, while the second address belongs to the contact group.
If you declare a named group within a class record, the group and its members inherit the accessibility of the record, if specified. Otherwise, they default to private.
You can specify more than one dimension. The number of dimensions in the group is the number of dimension arguments that you specify. The number of elements in the dimensioned group is the product of all dimension arguments. If initial values are specified in any fields that are members of a group, each declared element in the dimensioned group is initialized to the same initial values. Initial values are not allowed in overlay records.
If you specify a group size, the size of the fields and/or groups within that group cannot exceed the specified size. If they do exceed size, an error is generated. For example, the compiler generates an error for the following group because the size of fld1 (2000) is greater than the size specified for grp (10):
record rec group grp ,[15]a10 fld1 ,a2000 endgroup
All valid syntax for a group (multi-dimensioned fields, subgroups, dimensioned subgroups, and so forth) is allowed for subroutine and function arguments, including dimensioning of the group itself. For example, a subroutine header can be declared as follows:
subroutine mysub arg1 ,a group arg2 ,[*]a fld1 ,d5 fld2 ,[8]a3 endgroup arg3 ,a
Arg2[1].fld1 references the first five characters of the currently passed second argument, arg2[1].fld2[3] references characters 12 through 14, and so forth.
Object handles are not allowed within an argument group. For example, you cannot declare an argument with a data type of @class within a group. |
See also
- Variable path specifications for information about referencing group elements
- Defining a parameter for the syntax for declaring subroutine and function arguments
The example below defines the customer group, which has one dimension and 100 elements. Members of the customer group are the name field, the office group, and the contact group. The office group has two members, the bldg field and the first address group. The contact group has two members, the name field and the second address group. Each address group has two members, the street and zip fields. Note again that Synergy DBL allows the two groups called address because they don’t belong to the same parent group.
record info group customer ,[100]a name ,a30 group office ,a bldg ,a20 group address ,a street ,a40 zip ,d10 endgroup endgroup group contact ,a name ,a40 group address ,a street ,a40 zip ,d10 endgroup endgroup endgroup