FN_E$DCP - Decompose ?-separated data
Inclusion in RPG source
- C /COPY E$LIB/SRC(ILE),FN_E$DCP
- EXSR E$DCP
- @DCP (a256)
- Field to contain data to decompose.
- @DCC (a1)
- Decomposition character. The character that separates the values from each-other.
- @DCR (a256)
- Field which contains one column of decomposed data, after each subsequent call to E$DCP.
What it does
- The routine walks through a text string which holds columns with data, separated by a certain character, mostly a TAB or a SEMI-COLON. This character can be set in the input parameter @DCC (DeComposition Character). If @DCC is blank at the time of the call, the routine defaults to a COLON.
- Example strings with data:
- With each call, the next column is processed and returned in the field @DCR (DeComposition Result).
* If you know how many columns your DBDATA has: * C MOVEL';' @DCC C MOVELDBDATA @DCP P C EXSR E$DCP C MOVEL@DCR DBCOL1 P C EXSR E$DCP C MOVEL@DCR DBCOL2 P * A number, right align it in the alphanumeric field C EXSR E$DCP C MOVEL@DCR @ALR P C EXSR E$ALR C MOVE @ALR DBNUM3 * * If you don't know in advance how many columns to process, * you can test the internal column counter @DX if it has * reached zero. This counter counts the number of columns * to process at the first call. When it has reached zero, * you're done: * * Create a TAB character C MOVEL*BLANKS TAB 1 C BITOF'01234567'TAB C BITON'57' TAB * and use it as the separation character C MOVELTAB @DCC * C MOVELDBDATA @DCP P C EXSR E$DCP C MOVEL@DCR DBCOL1 P C @DX CABEQ*ZEROS TAG99 C EXSR E$DCP C MOVEL@DCR DBCOL2 P C @DX CABEQ*ZEROS TAG99 C EXSR E$DCP C MOVEL@DCR DBCOL3 P C ... *
Go to download page