THP is a "Tcl Hypertext Pre-processor"
What does this mean?
It is a server side pre-processor for documents that contain a mixture of HTML and Tcl commands.
In principle, it works much the same as similar scripted documents that use PHP or ASP.
THP works as a CGI language with web servers like Apache (as in the examples on this site) or the excellent TclHttpd.
Whereas a traditional CGI script (for this example, hosted on a Unix like platform) would execute a CGI script to directly generate dynamic content, THP achieves simple pre-processing of the called file by early termination of the called script and replacement with another script to pre-process the original file and generate output. Although this suffers a small overhead in the operating system having to re-open the same script twice, the resulting simplicity in authoring web-content is probably worth it. THP has some stiff competition in the world of web content generation, so it is of prime importance that THP enables a programmer with Tcl skills to very quickly start writing CGI scripts. Other web tools make use of loadable web-server libraries (such as mod-perl and mod-php for Apache) and it would be possible to implement THP in a similar way to remove the need for double-loading of content, but many users do not have the luxury of configuring their web-server and simply wish to rapidly develop simple dynamic content and forms.
THP allows the user access to all standard Tcl commands and any libraries they wish to load using package require ...
It is probably a good idea to use extensions such as ncgi and html from Tcllib to remove the need for complicated parsing of CGI Query variables, as Tcllib already provides some great tools and is widely available (and comes as standard with ActiveTcl distributions). See elsewhere for explanation of packages/extensions.
The only additional commands that THP provides are write and writeln, which are short forms of puts -nonewline stdout and puts stdout. Use of these two commands is encouraged, with use of puts reserved for writing to files.
See ... Example 1