A STRUCTURE BLOCK TYPE declaration provides a method of grouping together data and procedures that act upon that data into a logical unit, and have the data persist past block exit of those procedures. Structure block variables and structure block arrays can be declared from the STRUCTURE BLOCK TYPE declaration.
<structure block type declaration>
──┬─<local structure block type declaration>──┬────────────────────────┤ └─<global structure block type declaration>─┘
<local structure block type declaration>
── TYPE STRUCTURE BLOCK ──<identifier>── ; ── BEGIN ───────────────────► ►─<declaration list>── END ────────────────────────────────────────────┤
There are restrictions on what can be declared in the declaration list. The following cannot be declared within a structure block:
-
<database declaration>
-
<label declaration>
-
<switch label declaration>
-
<dictionary option>
-
<dump declaration>
-
<exception procedure declaration>
-
<exportlibrary declaration>
-
<transaction base declaration>
-
<transaction record declaration>
-
<transaction record array declaration>
-
<transaction declaration>
PROLOG PROCEDURE declarations and PENDING PROCEDURE declarations can only be located within a structure block or connection block.
A simple variable declared with the OWN specification in a structure block has one value for all structure block variables and arrays with the type of that structure block. This enables all structure block variables and arrays with the same structure block type to share a variable.
A structure block variable or a structure block array can be declared within structure or connection blocks, but a structure block variable or array cannot be declared with the type of the inner structure block outside the outer structure or connection block.
| Note: | An EVENT or EVENT ARRAY element that is declared in the <declaration list> of a STRUCTURE BLOCK TYPE declaration cannot be used as the <event part> of a direct I/O statement unless the direct array involved is declared in the same structure block and both are items of the same instance of that type. |
<global structure block type declaration>
──┬─<forward global structure block type declaration>──┬───────────────┤ └─<external global structure block type declaration>─┘
A global structure block can appear only in the global part of a program unit and cannot be nested. Global structure blocks enable the replacement binding of structure block procedures.
<forward global structure block type declaration>
── TYPE STRUCTURE BLOCK ──<identifier>── ; ── FORWARD ─────────────────┤
Structure blocks can be declared FORWARD within the global part of a subprogram. The global structure block then can be used for structure block variable declarations within the global part. The global structure block must be fully specified before it is referenced. This syntax is used when the subprogram procedure references a structure block item from outside the structure block.
<external global structure block type declaration>
── TYPE STRUCTURE BLOCK ──<identifier>── ; ── EXTERNAL ────────────────┤
The EXTERNAL structure block sets up the environment for structure block pending procedures in the subprogram to be bound to a host. Only those structure block items that are referenced by pending procedures need to be specified in the subprogram structure block declaration. The local declarations of the structure block items in the host that are not referenced by pending procedures do not need to be specified in the subprogram. This enables pending procedures in the subprogram to be bound without having to fully declare the entire structure block. EXTERNAL structure blocks cannot be bound. EXTERNAL structure blocks must be declared at level 3.
For more information about structure block binding, refer to the Binder Programming Reference Manual.
Identifiers
<structure block type identifier>
An identifier that is associated with a structured block type in a STRUCTURE BLOCK TYPE declaration.
Referencing Structure Block Items Outside the Structure Block
<structure block item designator>
──<structure block qualifier>──<structure block item>──────────────────┤
┌◄──────────────────────────────────────────────┐
──┴─┬─<structure block variable identifier>─┬─ . ─┴────────────────────┤
├─<structure block reference variable>──┤
└─<structure block array element>───────┘
Any identifier that was declared inside a STRUCTURE BLOCK TYPE declaration.
Use the structure block qualifier to identify items of a structure block that are referenced outside the structure block. The following types of structure block items can be referenced outside the structure block:
|
procedure variables |
structure block variables |
structure block arrays |
structure block reference variables |
|
connection libraries |
connection block reference variables |
event variables |
event arrays |
|
interlock variables |
interlock arrays |
BOOLEAN variables |
COMPLEX variables |
|
DOUBLE variables |
INTEGER variables |
REAL variables |
BOOLEAN arrays |
|
COMPLEX arrays |
DOUBLE arrays |
INTEGER arrays |
REAL arrays |
|
array references |
ASCII character arrays |
EBCDIC character arrays |
HEX character arrays |
|
DINTEGER variables |
DINTEGER arrays |
Procedures declared within an EXTERNAL structure block can be declared only as NULL or PENDING. A structure block procedure can be declared as NULL in an EXTERNAL structure block in a subprogram. The procedure serves as a placeholder for a procedure that is referenced by the pending procedure that is to be bound.

