Formatting output is quite easy. For each identifier or literal
value on the argument list, use:
     Value : field_width
The output is right-justified in a field of the specified integer
width. If the width is not long enough for the data, the width
specification will be ignored and the data will be displayed
in its entirety (except for real values -- see below).
Suppose we had:
     write ('Hi':10, 5:4, 5673:2);
The output (with a dash simulating the space) would be:
     --------Hi---55673
For real values, you can use the aforementioned syntax to display
scientific notation in a specified field width, or you can
convert to fixed notation with:
    
Value : field_width : decimal_field_width
The field width is the total field width, including the decimal
part. The whole number part is always displayed fully, so if you
have not allocated enough space, it will be displayed anyway.
However, if the number of decimal digits exceeds the specified
decimal field width, the output will be rounded to the specified
number of places (though the variable itself is not changed).
So
     write (573549.56792:20:2);
would look like:
     -----------573549.57
![]() Previous lesson |
![]() Next lesson |
![]() Contents |
![]() Index |
![]() e-mail me |