home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power CD-ROM!! 7
/
POWERCD7.ISO
/
os2
/
etelr212
/
sformat.vrm
< prev
next >
Wrap
Text File
|
1994-09-01
|
4KB
|
127 lines
/* Custom mainline for macro */
signal on SYNTAX name _VRESyntax
signal _VREMain
_VRESyntax:
parse source . . _VRESourceSpec
call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
exit 32000
_VREMain:
/*:VRX Main
*/
Main:
/***********************************************/
/* VX-Rexx Macro to strip char. strings from */
/* amounts & put them back again. */
/* Please do not modify */
/***********************************************/
signalled = 1
parse upper arg value action .
call VRMethod 'Application', 'GetVar', 'currency.'
sDecimal = currency.5
iDigits = currency.2
sThousand = currency.4
if action = 'STRIP' then
signal iStrip
minus = 0
if value = '' | DataType( value ) <> 'NUM' then
value = 0
if value = 0 then do
value = 0
signalled = 0
call iStrip
end
valLen = Length( value )
if valLen = 1 then do
value = '0'||value
valLen = 2
end
pos = valLen - iDigits
if( POS( '.', sDecimal ) <> 0 )then
value = Insert( '.', value, pos )
if( POS( ',', sDecimal ) <> 0 )then
value = Insert( ',', value, pos )
if( Left( value, 1 ) = '-' )then do
minus = 1
value = Strip( value, 'L', '-' )
end
if POS( '.', sDecimal ) <> 0 then
parse var value dollar '.' cent
if POS( ',', sDecimal ) <> 0 then
parse var value dollar ',' cent
if Length( dollar ) >= 4 then do
NewDollar = ''
Remainder = Right( dollar, 3 )
do until Remainder = ''
NewDollar = Remainder||NewDollar
if( Length( dollar ) <= 2 )then
leave
dollar = DelStr( dollar, Length( dollar) - 2 )
remainder = Right( dollar, 3 )
if remainder = '' then
leave
if POS( ',', sThousand ) <> 0 then
NewDollar = ','||NewDollar
if POS( '.', sThousand ) <> 0 then
NewDollar = '.'||NewDollar
if POS( "'", sThousand ) <> 0 then
NewDollar = "'"||NewDollar
if POS( ';', sThousand ) <> 0 then
NewDollar = ';'||NewDollar
if POS( ' ', sThousand ) <> 0 then
NewDollar = ' '||NewDollar
end
dollar = NewDollar
end
if( POS( '.', sDecimal ) <> 0 )then
value = dollar||'.'||cent
if( POS( ',', sDecimal ) <> 0 )then
value = dollar||','||cent
if dollar = 0 & POS( '0', iLzero ) <> 0 then
value = DelStr( value, 1, 1 )
value = Strip( value, 'L' )
if minus = 1 then value = '-'||value
drop dollar cent pos newdollar remainder centlen valLen minus
rc = value
call VRMethod 'Application', 'PutVar', 'rc'
exit
iStrip:
minus = 0
if( Left( value, 1 ) = '-' )then
minus = 1
if POS( '.', sDecimal ) <> 0 then
parse var value dollars '.' cents
if POS( ',', sDecimal ) <> 0 then
parse var value dollars ',' cents
CentLen = Length( cents )
if CentLen <> 0 then do
if CentLen < iDigits then
do iDigits - Centlen
cents = cents||'0'
end
if CentLen > iDigits then
cents = DelStr( cents, ( Length( value ) - ( CentLen - iDigits ) + 1 ) )
end
if CentLen = 0 then
do iDigits
cents = cents||'0'
end
value = dollars||cents
valLen = Length( value )
do i = 1 to valLen
if Datatype( SubStr( value, i, 1 ) ) = 'CHAR' then
value = DelStr( value, i, 1 )
end
drop dollars cents CentLen i
if minus = 1 then
value = '-'||value
if signalled = 0 then
return
rc = value
call VRMethod 'Application', 'PutVar', 'rc'
exit