Figure 3
/* */
number = 123.45
say FORMAT( number, 3, 0 ) => 123
say FORMAT( number, 3, 1 ) => 123.4
say FORMAT( number, 3, 2 ) => 123.45
say FORMAT( number, 3, 3 ) => 123.450
say FORMAT( number, 2, 3 ) => error
Note that the fifth SAY instruction results in
the following error:
7 +++ Say FORMAT(number, 2, 3)
REX0040: Error 40 running 9601FG03.CMD,
line 7: Incorrect call to routine
because the number of digits to the left of
the decimal point in number exceeds the
number of places indicated in
FORMAT(number, 2, 3). You always have to
be sure that the number of integer digits in
the value you try to format with the FORMAT() function doesn't exceed the number of
positions specified as the second, optional parameter to the FORMAT() function. If the second
parameter is omitted, the value is displayed without leading zeroes, unless the number is
less than 1.0 in which case one zero will precede the decimal point. The FORMAT() function
also results in the returned value being rounded at one greater than the number of decimal
positions specified. Hence, in the second SAY example in Figure 3 the value returned is
rounded at the second decimal digit.
In summary, you can present data in a comfortable, readable format with REXX
without very much effort. As with all data formatting, a little careful thought and planning
will save you a considerable amount of effort.
Object REXX
As I write this column, I have come to the conclusion that Object REXX may be
dangling in the breeze. The person who has served as the lead developer of Object REXX for
the past couple of years has moved on and is entrenched in his new surroundings - not the
IBM Glendale Laboratories in Endicott, NY. I have been told that the new REXXUTIL API that
I wrote about in my