Hello, I’m having an issue adding amounts, the source is a string. In this example, I’m trying to add $88.20, $46.00-, and $1844.23. Using either strtocur or strtofloat to add the amounts, is not taking into consideration the negative amount. On the other hand, using the @FormatAmountstr function, it does substract -$46 from $88 , but is not reading $1844.23 (I’m guessing is the empty field, because the description was split in two lines). Any idea will be much appreciated, thank you.
Here’s the code:
define(&99, integer, 1)
define(&TotalAmountC, currency, 0.00)
define(&TotalAmountM, measure, 0.00)
for(&99, 1, 1, subreccount())
if(trim(Field('suba',&99))='99')
if(or(eq(trim(Field('trans_code',&99)),'TRANS'),eq(trim(Field('trans_code',&99)),'PURCH')))
%%Just Showing Data
Showright('Show ' +trim(Field('AMOUNT',&99)))
CRLF(0.25)
%%Using Currency
&TotalAmountC:=&TotalAmountC + (strtocur(trim(Field('amount',&99))))
Showcenter('Currency ' +curtostr(&TotalAmountC))
CRLF(0.25)
%%Using Measure
&TotalAmountM:=&TotalAmountM+ (strtofloat(@FormatAmountstr(trim(Field('amount',&99)), ',') ))
Show('Measure ' +floattostr(&TotalAmountM))
CRLF(0.25)
endif()
endif()
endfor()
CRLF(0.35)
Showright(‘Currency $’ + @FormatAmountstr(curtostr(&TotalAmountC),‘,’))
CRLF(0.25)
Showright(‘Measure $’ + @FormatAmountstr(floattostr(&TotalAmountM),‘,’))