Here is your chance to become famous and win fabulous prizes (or maybe
not).  I will include this as an example file for .tcl files, but if
anyone would like to try their hand at making something cooler (while
still clear and leggible), it would be welcome.  Actually, same thing
goes for examples.ttml...:-)

# we have complete access to the interpreter here, so it is best to
# run per-page code in a namespace, just like we do with .ttml pages.

proc getcode { filename } {
    set fl [ open $filename r ]
    set sourcecode [ read $fl ]
    close $fl
    regsub -all "&" "$sourcecode" "\\&" sourcecode
    regsub -all "<" "$sourcecode" "\\&lt;" sourcecode
    regsub -all ">" "$sourcecode" "\\&gt;" sourcecode
    return $sourcecode
}

if { ! [ info exists header ] } {
    set header {
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
        <head>
        <title>.tcl example</title>
        </head> 
        <body bgcolor="#ffffff">
    }
}

if { ! [ info exists footer ] } {
    set footer {
        </body>
        </html>
    }
}

namespace eval request {
    hgetvars
    hputs $header
    hputs {
        <p>This is an example of a .tcl file being processed in mod_dtcl</p>
        <p>Here is the source code:</p>
        <hr>
        <pre>}
    hputs [ getcode $ENVS(SCRIPT_FILENAME) ]
    hputs {</pre>
        <hr>}
    hputs $footer
}

-- 
David N. Welton
Free Software: http://people.debian.org/~davidw/
   Apache Tcl: http://tcl.apache.org/
     Personal: http://www.efn.org/~davidw/
         Work: http://www.innominate.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to