write(f,expr);
The "write" procedure writes the value of an expression to an output file. It is equivalent to
f^ := expr; put(f);
The form
write(f,exp1,exp2,exp3,...,expN);
is equivalent to
write(f,exp1); write(f,exp2); ... write(f,expN);
Special processing is available if "f" has the type "text". In this case, the expression "expr" may have several different types.
Output expressions may be followed with field widths of the form ":M" where M is a strictly positive integer, as in
write(f,i:5);
This construct is called a "field width" and gives the minimum number of characters that should be used when outputting the expression's value. If the expression is "char", "integer", "boolean" or "real", the output will be padded on the left with blanks, if necessary. If the expression is "packed array of char", the string will be padded on the right with trailing blanks.
In addition to a field width, real expressions may have a "precision". This is written as ":N" where N is a strictly positive integer, as in
write(f,r:7:2);
The integer N indicates how many significant digits should be displayed following the real number's decimal point.
a := 1; b := 3.0; c := 'c'; write(a:4,b:7:2,c:3); {Will write out bbb4bbb3.00bbc where "b" indicates a blank.}
Copyright © 1996, Thinkage Ltd.