TACL Reference Manual

Variables
HP NonStop TACL Reference Manual429513-018
4-27
Accessing Structured Data
You can use the #SETV built-in function to copy structures (as well as other types of
variables). The output variable level must already exist; its original type and data are
lost. The output variable level becomes a structure identical to the input structure and
has its own copy of the data.
This is a brief summary of what you can and cannot do when copying STRUCT data.
Suppose you had created this STRUCT to contain an escape control character (ASCII
27) followed by a vertical-line character; this combination clears the screen when sent
to 653x terminals. To assign the data to a text variable for ease of use, enter:
[#DEF makecs STRUCT
BEGIN
BYTE b(0:1) VALUE 27 73;
CHAR c(0:1) REDEFINES b;
END;
]
#PUSH cs
To do so, you could use one of these #SET calls:
#SET cs [makecs:c(0:1)]
#SETV cs "[makecs:c(0:1)]"
but you could not use this statement:
#SETV cs makecs:c(0:1)
You can assign structures or substructures with #SETV, but not specific data items of a
structure. (If you had defined B and C as substructures of MAKECS, you could use the
preceding function call, but it would change CS from a simple text variable to a
STRUCT identical to MAKECS). Nor could you use:
#SETBYTES cs makecs:c(0:1)
because CS is a text variable and #SETBYTES requires that both source and
destination be structured variables.
If you had a STRUCT defined as:
[#DEF arrays STRUCT
BEGIN
INT array^1 (1:100);
CHAR array^2 (0:16) VALUE "This is a ""VALUE""";
END;
]
you could copy specific elements of array^1 or array^2 to another variable in this way:
#SET halfnums [arrays:array^1(1:50)]
#SET firstword [arrays:array^2(0:3)]
Data retrieved from a structure item is presented in a standard representation
appropriate for the type of that item.