home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
APPS
/
PROG
/
REXX
/
CMD
/
EDIT.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-07-30
|
3KB
|
48 lines
/*----------------------------------------------------------------*/
/* */
/* EDIT REXX function */
/*----------------------------------------------------------------*/
/* */
/* The following REXX subroutine / function will return an */
/* edited number, with or without an imbedded decimal point, */
/* with commas inserted appropriately. For example: */
/* */
/* EDIT(12345) */
/* */
/* will return 12,345; and */
/* */
/* EDIT(12345.67) */
/* */
/* will return 12,345.67. */
/* */
/* The intent behind the creation of this function was speed. */
/* it is being released to the public domain by the author, */
/* Dick Goran (CompuServe PPN 72200,347). */
/* */
/*----------------------------------------------------------------*/
EDIT:
/* first time here, build translate tables */
if LEFT(e1, 1) <> '01'x then
do
e1 = XRANGE('01'x, '19'x)
e2 = XRANGE('01'x, '03'x) || '19'x ||,
XRANGE('04'x, '06'x) || '19'x ||,
XRANGE('07'x, '09'x) || '19'x ||,
XRANGE('0A'x, '0C'x) || '19'x ||,
XRANGE('0D'x, '0F'x) || '19'x ||,
XRANGE('10'x, '12'x) || '19'x ||,
XRANGE('13'x, '15'x) || '19'x ||,
XRANGE('16'x, '18'x)
end
period_position = POS( '.', ARG(1) )
if period_position = 0 then
source = RIGHT( ARG(1), LENGTH(e1) - 1 ) || ' '
else
source = RIGHT( LEFT( ARG(1), period_position - 1 ), LENGTH(e1) - 1 ) || ' '
if period_position = 0 then
return STRIP( TRANSLATE( TRANSLATE( e2, source, e1), ',', ' '), 'B', ',')
else
return STRIP( TRANSLATE( TRANSLATE( e2, source, e1), ',', ' '), 'B', ','),
|| RIGHT( ARG(1), LENGTH(ARG(1)) - period_position + 1)