HP 3000 Manuals

UNPACK [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

UNPACK 

The UNPACK statement assigns the values of individual data items
contained in one scalar string variable to one or more HP Business
BASIC/XL variables.  The correspondence of the values in the scalar
string variable is determined by the order of the variables listed in the
referenced PACKFMT statement.

Syntax 

UNPACK USING line_id; str_var 

Parameters 

line_id          Specifies the program line of the appropriate PACKFMT
                 statement that specifies the variables to be unpacked
                 and the current format in which they are packed within
                 str_var.

str_var          Scalar string variable from which variables are to be
                 unpacked.

Examples 

The following example shows the use of the UNPACK statement.  Lines 120
and 130 contain the PACKFMT statements that the UNPACK statements use.
Lines 210 and 220 PACK the data using those PACKFMT statements, and lines
235 and 236 UNPACK the data, and assigns them to the referenced
variables.

     100 INTEGER Number, Times(4)
     105 INTEGER Num, N1(4)
     110 DIM String$[10], S1$[10], S2$[10]
     115 DIM A$[10], P1$[60], P2$[60]
     120 Pack1: PACKFMT Number,String$,A$,Times(*)
     130 Pack2: PACKFMT Times,SKIP 2,String$,SKIP 1,Number,SKIP 1,A$[3;5]
     140 Number=1234
     150 Times(1)=65
     160 Times(2)=73
     170 Times(3)=42
     180 Times(4)=90
     190 String$="abcd"
     200 A$="efghi"
     210 PACK USING Pack1; P1$
     220 PACK USING Pack2; P2$
     230 Pack3: PACKFMT Num,S1$,S2$,N1(*)
     235 UNPACK USING Pack3;P1$
     236 PRINT Num,S1$,S2$,(FOR I=1 TO 4, N1(I))
     240 Pack4: PACKFMT N1,SKIP 2,S1$,SKIP 1,Num,SKIP 1,S2$[3;5]
     245 UNPACK USING Pack4; P2$
     246 PRINT N1(1),N1(2),N1(3),N1(4),S1$,Num,S2$
     250 END



MPE/iX 5.0 Documentation