The CleanNum procedure filters a character field by stripping out any non numeric characters. It also compresses and embedded blanks that may exist in the variable.
By default, the digits 0 to 9, a U.S. decimal notation (.) and the minus symbol (-) are retained
packed-decimal-value CleanNum( szSrcValue 256A Const Varying szSaveChar 30A Const Varying OPTIONS(*NOPASS) ) |
See also: CharToNum, NumToZoned, NumToChar |
|
Original Value |
Cleaned Up Value |
| '12,345.60 CR' | '12345.60' |
| '<<12345.60>>' | '12345.60' |
| '(( 12,345,678 ))' | '12345678' |
If the function succeeds, the return value is a character string that has only valid numeric data stored in it.
If the function fails, the return value is empty.
This procedure is provided primarily for CGI and EDI applications that need to process all data as text.
Example
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++++++++++
D szWebData S 12A Inz('<<1,321.50>>')
D nBid S 7P 2
C Eval szWebData = CleanNum(szWebData)
Before the CleanNum() procedure runs, the szWebData field contains: '<<1,321.50>>'
After the CleanNum() procedure runs, the szWebData field contains: '1321.50'