PACK


 

The PACK instruction appends one or more variables from a list into a single destination character variable. The instruction uses the following format:

 

 

[label]

PACK

{dest}{sep}{source}

 

Where:

label

Optional. A Program Execution Label.

dest

Required. A previously defined Character String Variable or National Character String Variable that receives the appended source variables.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

source

Required. A previously defined Character String Variable, National Character String Variable, Numeric Variable, a list of string and/or numeric variables, String Expression, or a VARLIST of string and/or numeric variables that are appended together and placed in the {dest} operand.

Flags Affected: EOS

Note the following:

  1. The transfer process is exactly the same as:

  2.  

     

    CLEAR

    {dest}

     

    APPEND

    {source item 1} TO {dest}

     

    APPEND

    {source item 2} TO {dest}

     

    APPEND

    {source item n} TO {dest}

     

    RESET

    {dest}

     

  3. Only the {dest} operand changes. All other operands remain unchanged.

  4. The criteria for transferring the data from {source} is as follows:

  5. Generate/bullet1.gif    If a character string variable, the Logical String is transferred.

    Generate/bullet1.gif    If a Null String variable, it is bypassed.

    Generate/bullet1.gif    If a numeric variable, the Physical String is transferred.

    Generate/bullet1.gif    If a string literal, the entire literal contents are transferred.

    Generate/bullet1.gif    If an integer variable, the entire variable is transferred in reverse byte order sequence, i.e., the least significant byte is moved to the next available byte in the {dest} field.

    Generate/bullet1.gif    If an ARRAY variable without a specific array element is used, all array elements are transferred. Otherwise, only the specific array element is transferred.

  6. The Form Pointer of {dest} is set to one and the Length Pointer is set to the last character transferred. If all the list items are null, {dest} is set to null.

  7. If {dest} is too small, the remaining characters or list items are ignored and the EOS Condition Flag is set.

  8. {source} may be continued on additional lines by terminating each continued line with a colon (:) in place of the comma between the last list item on the continued line and the first list item on the new line.

 

Example 1:

 

  

PACK

RECVING FROM ITEM1,ITEM2,ITEM3,"END"

 

 

Variable

PL

FP

LP

Contents

Before:

RECVING

20

3

8

XXXXXXXX············

 

ITEM1

6

1

4

AAAA··

 

ITEM2

12

2

4

BBBBBBBBBBBB

 

ITEM3

6

 

 

·12345

 

After:

RECVING

20

1

16

AAAABBB·12345END····

 

All other variables remain unchanged

 

No Condition Flags are set (all FALSE).

 

Example 2:

 

 

Variable

PL

FP

LP

Contents

Before:

RECVING

20

1

13

AAAA111111CCC·······

 

ITEM1

10

1

10

AAAAAAAAAA

 

ITEM2

5

 

 

····1

 

ITEM3

15

5

15

XXXXCCCCCCCCCCC

 

After:

RECVING

20

1

20

AAAAAAAAAA····1CCCCC

 

All other variables remain unchanged

 

The EOS Condition Flag is set since RECVING was too small.

 

 

See Also: UNPACK, PACKKEY, Character String Instructions

 



PL/B Language Reference OR PACKKEY