EXPLODE


8.7B

 

The EXPLODE instruction disassembles a source variable string into one or more variables based on specified delimiter characters.

 

(1)

[label]

EXPLODE

{source}{sep}{delim}{sep}{dest}

(2)

[label]

EXPLODE

{source}{sep}{delim} GIVING {result}{sep}{dest}

 

Where:

label

Optional. A Program Execution Label.

source

Required. A previously defined Character String Variable or FORM variable that is disassembled.

sep

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

delim

Required. A previously defined Character String Variable, Literal, decimal, octal, or hexadecimal value that defines delimiter values that separate individual fields in the {source} variable.

dest

Required. A previously defined Character String Variable, Numeric Variable, a list of string and/or numeric variables, a VARLIST of string and/or numeric variables, an Array, or an object that receive the contents of the {source} operand.

result

Required. A previously defined Numeric Variable that receives the number of items that have been processed from the {source} and stored into the variables of the {dest}

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. If the {delim} variable is a Null String, the EXPLODE instruction executes exactly the same as an UNPACK instruction. This includes disassembly of the {source} and the flag states.

  2. When {delim} is a Character String Variable or a Literal, the logical string specifies the delimiter characters that separate individual fields in the {source} variable. The maximum number of delimiter characters supported in the {delim} variable is 256.

  3. When {delim} is a decimal, octal, or hex value, the numeric value identifies the delimiter character that separates individual fields in the {source} variable. The value must be between zero to 255. A compiler error will occur if the value is not in this range.

  4. If {delim} is NULL, the EOS and OVER flags are set the same as an UNPACK statement and the ZERO flag is not affected.

  5. If {delim} is not NULL, the ZERO flag is indicates whether all of the fields in the {source} variable were processed and transferred to the {dest} variables. The ZERO flag is set if all of the {source} variable fields were processed and FALSE when more {source} variable fields exist.

  6. EXPLODE does affect the {source} variable Form Pointer setting when the ZERO flag to FALSE.

  7. When more fields exist in the {source} variable as indicated by the ZERO flag being FALSE, the Form Pointer of {source} is set to the beginning of the next field that is processed. If all of the fields in the {source} variable are processed and the ZERO flag is set FALSE, the {source} variable Form Pointer is unchanged.

  8. No changes are made to the {source} variable if it is a Numeric Variable.

  9. The processing implemented for the EXPLODE statement does not conform to a MOVE operation.

  10. An F09 error will occur if a {dest} variable being processed is the same as the {source} variable. The {source} cannot be specified in the {dest} EXPLODE variable list. In addition, a F09 error will occur if a {dest} variable is a GUI Object variable and the {delim} parameter is NULL.

  11. If a {dest} variable is a valid object, the corresponding {source} field string is placed into the object in the same manner as a SETITEM operation with a zero value {item} parameter. If the {source} field is NULL, the object is cleared. This operation is only allowed for the following objects: BUTTON, CHECKBOX, COMBOBOX, EDITTEXT, EDITDATETIME, EDITNUMBER, RICHEDITTEXT, LABELTEXT, RADIO, and STATTEXT.

  12. If a {dest} variable is a valid COMBOBOX, the corresponding {source} field string is placed into the COMBOBOX in the same manner as a SETITEM operation with a negative one (-1) value {item} parameter. If the {source} field is NULL, the COMBOBOX is cleared.

  13. Both the PLBSERVE and PLBCLIENT must be a version 9.3A or later to allow use of a COMBOBOX.

 

 

See Also: Example Code, IMPLODE, PACK, PACKKEY, Character String Instructions

 



PL/B Language Reference ENDSET EXTEND