Back to List
Placeholder | Replace With |
num | A number value, such as a Number variable, to be divided (a numerator) |
num | A number value, such as a Number variable, by which to divide (a denominator) |
The remainder expression returns the remainder of a division. If the denominator is a zero, HotDocs generates a divide by zero error.
In this basic example, HotDocs divides 10 by 3. The remainder of that division is 1:
remainder( 10, 3 )
In this next example, a user enters a time value in number format (such as 6 hours). However, using the remainder expression (as well as truncate and round), HotDocs causes the value to appear in hours:minutes format:
format( truncate( NumberOfHours, 0 ), "9" ) + ":" +
format( round( 60 * remainder( NumberOfHours, 1 ), 0 ), "09" )
This script takes the value of NumberOfHours, which may have a decimal value, and truncates it to a whole number. Then, using the remainder expression, NumberOfHours is divided by 1 and the remainder of the division is multiplied by 60 (as in 60 minutes). HotDocs then rounds that value and brings these two values together in a string, separated by a colon. The value is then formatted correctly.
Back to List