Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Writeln Procedure
◄Summary► ◄Details► ◄Example► ◄Back►
Arguments
file_variable Optional; text file (default is standard file
Input)
<expression> Optional; expression of any simple type
<format> Optional; depends on type of expression
Description
The Writeln procedure writes zero or more values followed by an
end-of-line (carriage-return and line-feed) to a disk file or
device. Writeln always appends to a file. The current position is
always at end-of-file.
The file must be a text file, opened for output with the Append or
Rewrite procedure. If no output file is specified, Writeln writes
to the standard text file Output. Standard output goes to the screen
unless redirected to a file by the DOS redirection operator, (>).
Use the Assign procedure to reenable redirection when using the Crt
unit.
If Writeln is called with no expressions, it writes an end-of-line
to the file. On the screen, it moves the cursor to the first column
on the next line.
The format argument is optional and varies with the expression
type:
1. For character, Boolean, or string output, the format is
<expression> [ : width ]
The width argument is a positive integer expression giving a
minimum field width. The characters are right justified within
the field if they fit. If they do not fit or if width is
omitted, the characters take as much space as needed.
For Boolean expressions, the output is a string of text,
either 'TRUE' or 'FALSE'.
2. For numeric output the format is
<expression> [ : width [ : places ] ]
The width and places arguments are positive integer
expressions that control the conversion format. The
expression is either an integer or a real type. The
formatting specification is the same as that passed to
the Str procedure.
The width argument gives the minimum field width. The number
is right justified within the field if it fits. For an
integer, if the number does not fit or if width is omitted,
the number takes as much space as needed. For a real number,
if width is less than 8, the value is ignored and a field
width of 8 is used. If width is omitted, a width of 23 is
assumed. The field width includes the decimal point and any
places after the decimal. A negative width is ignored.
The places argument gives the number of places to the right of
the decimal. This parameter applies only to real arguments
when width is specified. If places is greater than 18 or is
negative, 18 decimal places are used. Omit places or give a
negative value to write in scientific (engineering) notation.
Specify 0 places to round a real to the nearest whole number.
The output string for an integer has the form:
[-] <decimal digits>
The output string for a real number has the form:
[-] <digits> [.<digits>] [ {E│e} [+│-] <digits> ]
Numeric output in hexadecimal format is not possible.
If file_variable is not associated with a file or if the file is
not open when Writeln is called, an I/O error occurs.
If Writeln is called for a file opened for reading with Reset, an
I/O error occurs.
To prevent a program from halting with a run-time error when an I/O
error occurs, turn off I/O checking with {$I-} and check the return
value of the IOResult function.