PACK


ANSI, NCHAR

 

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, 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.

 

 

See Also: Example Code, UNPACK, PACKKEY, Character String Instructions

 



PL/B Language Reference OR PACKKEY