|The HotDocs Computation Archive|
SET Temp-n TO ( NumVar - TRUNCATE( NumVar, 0 ) ) * 100 "«NumVar:Nine» and " IF Temp-n = 0 RESULT + "no/100 Dollars" ELSE RESULT + "«Temp-n»/100 Dollars" END IF
You need one temporary number variable. I called mine Temp-n. Be sure to select each of its "Advanced" options.
Here's the logic:
Extract the decimal value from the number by truncating the number at the decimal and subtracting this from the original (e.g. 100.25 - 100 = .25). Then multiply the decimal by 100 to get a value usable for the fraction (.25 * 100 = 25, which will later be formatted as 25/100).
Now we convert NumVar into a string and format it as "Nine." This format omits the decimal value. Note that putting the number variable in chevrons inside of a pair of quotes is the same as doing "FORMAT( variable, example )" and it is much easier (see Computations #0048 and #0057).
Now we look at the decimal value. If it is 0, we append "no/100 Dollars" to the value we already have ("RESULT"). If the decimal has a value, we append the value as the numerator for the fraction.
This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.
(Go to the download page)