PLIPARSE
PLIPARSE parses a character string into substrings.
There must at least 3 arguments and no more than 64.
The first argument is the input string to be parsed (which can be any expression with CHARACTER type).
The arguments after that input string consist of an even number of pairs with each pair
consisting of
- an even number of pairs with each pair consisting of a target reference (or an *) and a separator
- an optional, last target argument that must be a reference (or * )
The first target argument after the first separator that is not found is assigned the remaining input and any remaining target arguments are assigned the quotation marks.
Any target argument that is not an * must have CHARACTER type and must be ASSIGNABLE.
The separators must all have CHARACTER type.
Example 1
Given
dcl x1 char(16) varying;
dcl x2 char(16) varying;
dcl x3 char(16) varying;
dcl x4 char(16) varying;
dcl s1 char value('KEY:');
dcl s2 char value('--');
dcl s3 char value('-');
input = '31415KEY:0123--45678-9';
call pliparse( input, x1, s1, x2, s2, x3, s3, x4 );
the target arguments will have the following values
x1 = '31415';
x2 = '0123';
x3 = '45678';
x4 = '9';
Example 2
In this example, "input" differs from the example above in that there is no "--"
Given
dcl x1 char(16) varying;
dcl x2 char(16) varying;
dcl x3 char(16) varying;
dcl x4 char(16) varying;
dcl s1 char value('KEY:');
dcl s2 char value('--');
dcl s3 char value('-');
input = '31415KEY:0123-45678-9';
call pliparse( input, x1, s1, x2, s2, x3, s3, x4 );
the target arguments will have the following values
x1 = '31415';
x2 = '0123-45678-9';
x3 = '';
x4 = '';
Example 3
Given
dcl x1 char(16) varying;
dcl x2 char(16) varying;
dcl x3 char(16) varying;
dcl x4 char(16) varying;
input = ' Alex Bruno';
call pliparse( input, x1, ' ', x2, ' ', x3, ' ', x4 );
the target arguments will have the following values
x1 = '';
x2 = 'Alex';
x3 = '';
x4 = 'Bruno';
Example 4
Given
dcl x1 char(16) varying;
dcl x2 char(16) varying;
dcl x3 char(16) varying;
dcl x4 char(16) varying;
input = collapse( ' Alex Bruno', ' ' );
call pliparse( input, x1, ' ', x2, ' ', x3, ' ', x4 );
the target arguments will have the following values
x1 = 'Alex';
x2 = 'Bruno';
x3 = '';
x4 = '';