Remove a Leading Zero from a Fraction

From HotDocs Wiki

Jump to: navigation, search

This feature uses the STRIP expression, which is only supported in HotDocs 2006 and later.

Sometimes you need to insert a fraction in your assembled document. If the fraction represents a value less than one, HotDosc inserts a leading zero. You can use the STRIP expression to remove the zero from the answer.

For example, say you are trying to insert the hours spent working on a project—in 15-minute increments. For those blocks of time less than an hour, you can have the answer merge as 3/4 hours, rather than 0 3/4 hours.

To do this, you would first create a Number variable with two decimal places. You may want to include a prompt explaining that answers have to be entered in decimals that most closely represent the quarter hour. Next, you will create a Computation variable where the answer should be merged. In the following example, the variable Num Var is formatted as text (using the FORMAT expression). The STRIP expression then strips the leading 0 ("0") from the answer—but only if it's the first character and not the last. (Character position is defined by the TRUE and FALSE parameters.)


STRIP((FORMAT(Num Var, "9 1/8")), "0", TRUE, FALSE)

Num Var Any Number variable with two decimal places.