WRITELN - write an output line of text.

Usage:

writeln(f,expr);

Where:

f
is a file variable with the type "text". If this argument is omitted, the default output unit "output" is used.
expr
is an expression whose value is "char", "integer", "real", "boolean", or "packed array of char". If an output expression is omitted, "writeln" simply writes a new-line character to "f".

Description:

The "writeln" procedure writes the value of an expression to an output text file. After the expression, it writes a new-line character to show the end of the output line.

Output expressions may be followed with field widths of the form ":M" where M is a strictly positive integer, as in

writeln(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

writeln(f,r:7:2);

The integer N indicates how many significant digits should be displayed following the real number's decimal point.

The form

writeln(f,exp1,exp2,exp3,...,expN);

is equivalent to

write(f,exp1);
write(f,exp2);
   ...
writeln(f,expN);

Examples:

a := 1; b := 3.0; c := 'c';
writeln(a:4,b:7:2,c:3);
{Will write out
bbb4bbb3.00bbc
where "b" indicates a blank.}

See Also:

expl pascal lib write

Copyright © 1996, Thinkage Ltd.