"«NumberVar:9999.99»" IF POSITION( RESULT , "." ) = 7 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 6 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 5 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 4 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 3 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 2 " " + RESULT ELSE IF POSITION( RESULT , "." ) = 1 " " + RESULT END IF
This computation pads the left side of a number with as many spaces as necessary to decimal-align the number with other numbers in a column. For example:
123456789.00
12345678.00
1234567.00
123456.00
12345.00
1234.00
123.00
12.00
1.00
The number variable NumberVar is first converted into a string. Then, using the POSITION model, we determine where the decimal falls in the string. By the decimal's position in the string we can determine how many spaces need to be added before the number.
This computation assumes a string that is ten characters long, including the decimal.
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.