Skip to content

UNPACK ARRAY

Puts Packed String into String Array

This directive re-DIMensions, restores, and populates an existing string array from a string that was packed into a format with the PACK ARRAY directive.

UNPACK ARRAY string-value,array-name[ALL][,ERR=line-ref|,ERC=error-code]
string-value
is any string, which represents the packed data of a string array.
array-name
is the name of an existing string array.
line-ref
is the program line number or label to branch to if an error is produced.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

If the values of the array elements are stored in the packed array string in a compressed format, they are uncompressed via the UCM() function.

If an array does not exist, an ERR=42 results.

If a packed array string is not in the proper format, an ERR=46 results.

DIM S$[-5:5];
FOR I=-5 TO 5;
S$[I]="ELEMENT "+STR(I);
NEXT I;
PACK ARRAY S$[ALL],P$;
DIM S$[1];
UNPACK ARRAY P$,S$[ALL]

restores the contents of the array S$[] from the string P$.

DIM S$[1];
P$=CHR(3)+BIN(-10,4)+BIN(10,4)+BIN(0,4)+BIN(10,4)+BIN(1,4)+
BIN(10,4);
UNPACK ARRAY P$,S$[ALL]

re-DIMensions the array S$[] as follows:

DIM S$[10:10,10,1:10]

PACK ARRAY directive

From the Thoroughbred Basic Language Reference, Volume III: R–Z, version 8.9.1. Open this page in the PDF