help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Procedures and functions] Reference for unit 'pwumain' (#powtils_main)

OutLn

Declaration

Source position: pwumain.pas line 131

procedure OutLn(

  const s: String

);

Notes

Use this procedure to write a line (with a feed at the end) directly to the browser output. The difference between this function and Out() is that OutLn() appends a carriage/linefeed.

You can still use the system.WriteLn procedure if writing to a text file handle, but if you call system writeln to standard out (web browser out) you will interfere with how OutLn handles headers, and gzip buffering (if on).

Tips

This is equivalent to WebWriteLn. The old WebWriteLn is still available for backwards compatibility.

It is recommended to not use system.writeln() for web output - instead, use OutLn.

This function appends a regular linefeed, it will not actually output a HTML break.

Example

uses
  pwumain;
begin
  outln('hi world'); 
  outln('hi planet'); // not on a new line in web browser but when you view html                
                      // source, it is.
end.

The reason OutLn does not output a brand new line to your browser is because of how HTML works. If we hardcoded an html break into this procedure, it would interfere with HTML and offer less flexibility. For example consider the <PRE> tag where we do not want HTML breaks, and OutLn therefore works as expected:

uses
  pwumain;
begin
  outln('<pre>');        // preserve formatting
  outln(  'hi world'); 
  outln(  'hi planet');  // does show new line in web browser 
  outln('</pre>');  
end.
You can build a function like below if you need an html break:
uses
  pwumain;

procedure writebr(s: string);
begin
  outln(s + '<br />');
end;

begin
  writebr('hi world'); 
  writebr('hi planet'); // does show new line in browser since <BR> is called
end;
Consider also the rapid-html units in the /extras/ folder of your download, which will contain a lot of these wrappers and html automation implemented already.





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505