"ŤAmount-n:Nine Dollars and Twelve Centsť" IF LAST( RESULT, 13 ) CONTAINS "and no cents" FIRST( RESULT, LENGTH( RESULT ) - 13 ) END IF
This computation formats a number variable, Amount-n, in the form "Nine Dollars and Twelve Cents." If, however, there is no cent value, the computation will trim off the string " and No Cents," returning only the dollar amount. For example:
$5.06 - Five Dollars and Six Cents
$5.00 - Five Dollars
To accomplish this, the computation is first set to the value of the number variable nAmount formatted as "Nine Dollars and Twelve Cents." We then look at this string (it is stored in RESULT) to see if its last 13 characters are " and no cents." If so, we trim off that part of the string. To do this, we take only the FIRST x characters of the string, where x is the length of the string - 13.
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.