Any ideas,
I've tried the following.
setProp cDisplaySepCurrency pValue
local tSepValue
if word 1 of the name of the target is not "field" then
return "Invalid target"
else if pValue is not a number then
return "Invalid value"
else
put format ("%1.0f", pValue) into pValue
put char -6 to -1 of pValue into tSepValue
put empty into char -6 to -1 of pValue
repeat while the number of chars in pValue > 0
put char -3 to -1 of pValue & comma before tSepValue
put empty into char -3 to -1 of pValue
end repeat
put "£" before tSepValue
put tSepValue into the target
end if
end cDisplaySepCurrency
then the calculation....
put the cDisplaySepCurrency of field "Purchase_Price_1" into v_Purchase_Price
put (v_Purchase_Price * 0.1) into v_Deposit
set the cDisplaySepCurrency of field "Deposit" to v_Deposit
I get just a zero value in field "Deposit" but don't know why?
Any thoughts appreciated.
Andrew
Calculating numbers with currency formating
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Calculating numbers with currency formating
Hi Andrew,
I think I recognise that setProp handler![Wink ;-)](./images/smilies/icon_wink.gif)
The reason it's not working in your situation is, I think, because the setProp handler intercepts the actual setting of the custom property to do some processing for the result you require. In this way Rev offers "virtual properties" that you can use where the original value passed to the handler is not stored, because the processed value is returned/handled/stored elsewhere. (ie the non-separated parameter value is volatile and the string of formatted currency characters is put in the field instead, with the numeric parameter lost.)
In the setProp handler, just before the end statement, include the line:
pass cDisplaySepCurrency
and that should allow the actual custom property to be set. You now have a visible field value with also the (naturally invisible) custom property recorded against the field object containing the original numeric value without the string separation chars, which will then be able to be interrogated and give you a value to use in setting the cDisplaySepCurrency of the other field.
I tried to explain this here: http://forums.runrev.com/phpBB2/viewtop ... 805#p12805 but I obviously didn't do a terribly good job.
HTH
SparkOut
I think I recognise that setProp handler
![Wink ;-)](./images/smilies/icon_wink.gif)
The reason it's not working in your situation is, I think, because the setProp handler intercepts the actual setting of the custom property to do some processing for the result you require. In this way Rev offers "virtual properties" that you can use where the original value passed to the handler is not stored, because the processed value is returned/handled/stored elsewhere. (ie the non-separated parameter value is volatile and the string of formatted currency characters is put in the field instead, with the numeric parameter lost.)
In the setProp handler, just before the end statement, include the line:
pass cDisplaySepCurrency
and that should allow the actual custom property to be set. You now have a visible field value with also the (naturally invisible) custom property recorded against the field object containing the original numeric value without the string separation chars, which will then be able to be interrogated and give you a value to use in setting the cDisplaySepCurrency of the other field.
I tried to explain this here: http://forums.runrev.com/phpBB2/viewtop ... 805#p12805 but I obviously didn't do a terribly good job.
HTH
SparkOut
Re: Calculating numbers with currency formating
SparkOut,
Many thanks for this it worked like a charm. Sorry for the re-post I had forgotten I had posted the same question over a year ago...
Andrew
Many thanks for this it worked like a charm. Sorry for the re-post I had forgotten I had posted the same question over a year ago...
Andrew