Hi Paul,
There is an entire table inside the code for Sbasic that determines output type of calculations based on the variable types of the two variables involved. In general, any one type plus/minus/divided by/multiplied by that same type returns that same type. So Int plus Int obviously returns Int. Same thing for Date, Time, Money, etc.
The reason I say in general is there are exceptions like String - String is not allowed as SBasic can not determine what "Bob" - "Banana" would be.(Obviously the answer is "Hungry" but I digress

)
So if you find yourself not getting the answer you want out of an equation, look at the types of your variables involved and see if perhaps you don't need to change one to a different type using one of the @To***() commands. One way to determine if you need to do this(It's actually the way I did it to get the numbers/dates for the previous post) is to use Writeln() to write out the result of each separate calculation. So say you have the equation of A = B + (B/(C-D)) I would fill that section up with debug like:
Writeln(C-D)
Writeln(B/(C-D))
Writeln(B + (B/(C-D)))
A = B + (B/(C-D))
Writeln(A)
This way you can see what each part of the equation is returning.
This is also why sometimes you'll see someone perform an operation on several lines when it could be crammed into one line like the above statement. They might write that same piece of code as
Var vTemp as WhateverTypeOfVariableTheyNeed
vTemp= C-D
vTemp = B/vTemp
vTemp = B+vTemp
A = vTemp
This allows them to write out vTemp at several points along the way and see where the error is coming from. Yes it takes up a few more lines but it's easier to troubleshoot then a line like
PrintString(@AsFormattedByLE(Total, 0, vSubTotal + (vSubTotal * (vTaxRate / 100)) + vShipping + vHandling + vFees + @XLookup(@FN, CustomerID, "Customers!ID", "Discount")), 650, vPageY, 100, "Arial", 16, 0, 1)
Note: I'm not saying you should have each operation on it's own line but sometimes building a large equation in pieces will save you a lot of time when/if something goes wrong with it.
Have a great weekend,
-Ray
P.S. I apologize for such a long post but hopefully others will find pieces of it useful in the future.