The DPARSE statement splits the elements of a delimited string into other variables. DPARSE.CSV is similar but unquotes strings according to the rules in the CSV standard.
DPARSE string, delimiter, var1, var2,...
DPARSE.CSV string, delimiter, var1, var2,...
The DPARSE statement extracts successive elements delimited by delimiter within string into the listed variables. A statement such as
DPARSE S, ",", A, B, C
is equivalent to
A = FIELD(S, ",", 1)
B = FIELD(S, ",", 2)
C = FIELD(S, ",", 3)
DPARSE.CSV extends this action by removing quotes that have been applied to meet the CSV standard. CSV format allows optional double quotes around items and specifies that these must be present when the item contains the delimiting character or a double quote. In the latter case, the embedded double quote will be represented by two adjacent double quotes.
READSEQ LINE FROM SEQ.F ELSE EXIT
STOCK.REC = ""
DPARSE LINE, ",", PART.NO, STOCK.REC<1>, STOCK.REC<2>
This loop dismantles a comma separated string to extract three elements.
S = 'abc,"de""f"'
DPARSE S, ',', A, B
DPARSE.CSV S, ',', A, B
This program will print
showing the difference between the DPARSE and DPARSE.CSV statements.