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



Notes

When building web programs with powtils, use webwrite and webwriteln instead of write() and writeln() when you display text in the web browser. If you use write() instead of webwrite() your web program is not guaranteed to function properly. This is because webwrite and webwriteln do some magic header initialization gzip buffering (if enabled), and sessions (if enabled) to work properly.

CGI programming requires header initialization - webwrite and webwriteln take care of this for you automatically. The powerful web utilities also include an option to utilize GZIP compression to save bandwidth. Web browsers are smart enough to decompress GZIP compressed output from a server if the headers are set correctly. The system functions write and writeln are not designed to work with GZIP compression, but webwrite and webwriteln are.

You can use write() and writeln() if you are writing to a text file handle, however do not use them to display text in the web browser.

Overloaded WriteLn() and Write()

We have made a writeln text driver but it is not used by the core developers at this time since functions such as WebWrite(), WebWriteF() and WebWriteA() work fine. The unit is called WebCrt if you are interested, however.

For Gurus and Experts only:

Even if you know what you are doing and are a seasoned developer, using write and writeln could cause confusion and odd behaviour.

Once you call webwrite, if gzip is off, you can actually use writeln and write from there on. This is because standard out is available through writeln once the headers have been initialized once by webwrite or webwriteln.

Rare case

However calling write() or writeln() in web programs that use Powtils is strongly discouraged, unless you have some specific situation that calls for it. For example if you are executing another program inside your CGI program using an Exec() of some sort, you may want to skip header initialization all together and just use writeln in that child program, since in the parent program you have already launched the headers with a webwrite() call. If you use webwrite inside a child process that is spitting text out to standard out already from a parent powtils program, then the headers will be initialized and output twice (from the parent first, then the child) which is not what you want.

If you have gzip enabled, launching a child process may not work at all if the child process spits regular text to standard out. When launching child processes that spit text to standard out, do not use gzip anywhere if you experience issues (gzip is enabled in the pwu config file and in the GZIP_ON define).

Using system.writeln() and system.write() in rare cases is an advanced topic which will be discussed in the documentation some time soon, in more detail.






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