Name

WriteLn Procedure

Syntax

procedure WriteLn(Expr:Width:Precision; ...);
procedure WriteLn(var F: TextFile; Expr:Width:Precision; ...);

Description

WriteLn is just like the Write procedure, except it prints a line ending after printing its arguments. A line ending is a carriage return followed by a line feed (#13#10). With no arguments, or only a TextFile argument, WriteLn prints only a line ending.

Tips and Tricks

  • If the file has not been assigned, Write reports I/O error 102.

  • If the file is not open for write access, Write reports I/O error 104.

  • When the write fails because the disk is full, sometimes Write reports the Windows error Error_Disk_Full (112); sometimes it reports I/O error 101.

  • If no TextFile is given as the first argument, WriteLn writes to Output.

  • See the Write procedure for a description of how to format the output.

Example

// Print a table of square roots.
WriteLn('Num   Square root');
for I := 1 to 10 do
  WriteLn(I:3, '':2, Sqrt(I):18:15);

See Also

BlockWrite Procedure, IOResult Function, Output Variable, ReadLn Procedure, TextFile Type, Write Procedure

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.