RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.WriteLn Function

Writes to a text file and adds an end-of-line marker.

Pascal
procedure WriteLn(P1); overload;
procedure WriteLn(P1; Pn); overload;
procedure WriteLn(var F: Text; P1); overload;
procedure WriteLn(var F: Text; P1; Pn); overload;
C++
WriteLn( P1);
WriteLn( P1,  Pn);
WriteLn(Text F,  P1);
WriteLn(Text F,  P1,  Pn);

WriteLn is an extension to the Write procedure, as it is defined for text files.  

The syntax shown here for the WriteLn procedure is an example that illustrates that WriteLn can take a variable number of arguments. 

After executing Write, WriteLn writes an end-of-line marker (line feed or carriage return/line feed) to the file.  

If F is omitted, the global variable Output is used, which accesses the processes standard input file. Use of Output in GUI applications raises special issues.  

Delphi Examples: 

 

{
This example assumes you are compiling as a console
application.  Notice how the form deactivates when the button
click procedure exits.
}

{$APPTYPE CONSOLE}

procedure TForm1.Button1Click(Sender: TObject);
var
  s : string;
begin
  Write('Enter a line of text: ');
  Readln(s);
  Writeln('You typed: ',s);
  Writeln('Hit <Enter> to exit');
  Readln;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!