Page 1 of 1

Rounding Variables (Currency Values)

Posted: Wed Nov 03, 2021 2:56 am
by Torano
So I'm working on a button that adds two monetary amounts, then multiplies it by a percentage. However, I come across two intermittent issues: One, an extra digit in the thousandth place, or a digit missing (0) in the hundredth place. Is there a simple (or simple-ish) way to check and correct the variable so it rounds properly?

Re: Rounding Variables (Currency Values)

Posted: Wed Nov 03, 2021 2:54 pm
by Wavget
Not sure this is simple-ish, but here is a solution.

{Var1=12.34} //store the result into Variable #1
{Length 2,{Var1}} //get the length of the number and store it into variable #2
{If (Var2=4) [{Var1}0]} //if the length is 4 the number is missing a zero. type the number and type an extra zero
{If (Var2=5) [{Var1}]} //if the length is 5 the number is correct, just type it
{If (Var2=6) [{Copy 1,5,3,{Var1}}{var3}]} //if the length is 6, copy the first 5 characters from variable #1 into variable #3 and then type it.

Some kind of format function would help here. I'm adding it to the TO DO list.