| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| <title>Tcl Scripts</title> |
| <link rel="stylesheet" href="../templates/wondrous/styles.css" type="text/css" /> |
| </head> |
| |
| <body> |
| <div id="container"> |
| <div id="header"> |
| <h1><a href="../index.html">Rivet</a></h1> |
| <h2 id="slogan">Webscripting for Tcl'ers</h2> |
| <div class="clear"></div> |
| </div> |
| <div id="body"> |
| <div id="content"> |
| <h2>Tcl Scripts</h2> |
| <div> |
| <p> |
| Pure Tcl scripts let you do the heavy lifting to control your application. A sensible |
| design pattern is to put most of your complex logic in these files, and then parse template |
| files to display the results. This means that those who are creating the HTML files don't |
| have to know much Tcl, and only need to call a few simple commands. |
| </p> |
| <p> |
| <pre class="programlisting">proc chat::model::getlines {user} { |
| set sk [chat::model::getsock] |
| puts $sk [list user $user cmd get msg ""] |
| if { ! [eof $sk] } { |
| gets $sk data |
| return "$data" |
| } else { |
| error "Problem with socket" |
| } |
| }</pre> |
| </p> |
| <p> |
| For instance scripts are useful when you want to have control of the http protocol and you are not transmitting |
| text/html data. See the example regarding the <a href="file%5fdownload.html">file download</a> |
| |
| |
| or the xml messaging in <a href="ajax.html">Ajax</a> |
| |
| development. |
| </p> |
| </div> |
| |
| |
| |
| <div class="contentbottom"> |
| |
| </div> |
| </div> |
| |
| <div class="sidebar"> |
| <ul> |
| <li id="news"> |
| <h4>News</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a href="rn%2d2%2d1.html">3 Mar 2014: Rivet 2.1.4 released</a> |
| </li> |
| <li class="navitem"> |
| <a href="rn%2d2%2d2.html">5 Dec 2015: Rivet 2.2.4 released</a> |
| </li> |
| <li class="navitem"> |
| <a href="rn%2d2%2d3.html">11 Nov 2017: Rivet 2.3.5 released</a> |
| </li> |
| <li class="navitem"> |
| <a href="rn%2d3%2d0.html">9 Feb 2018: Rivet 3.0.1 released</a> |
| </li> |
| </ul> |
| </li> |
| |
| </ul> |
| <ul> |
| <li id="home"> |
| <h4>Rivet</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a title="A home for Rivet" href="../index.html">Rivet Homepage</a> |
| </li> |
| <li class="navitem"> |
| <a title="Home of Apache Tcl related stuff" target="asf" href="http://tcl.apache.org/">Apache Tcl Home</a> |
| </li> |
| <li class="navitem"> |
| <a title="Getting Rivet" href="download.html">Getting Rivet</a> |
| </li> |
| <li class="navitem"> |
| <a title="Hello World!" href="hello%5fworld.html">Examples</a> |
| </li> |
| <li class="navitem"> |
| <a title="The Rivet development team" href="about.html">About Us - Contact</a> |
| </li> |
| </ul> |
| </li> |
| <li id="tcl"> |
| <h4>Tcl/Tk</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a title="The Tcl Developer Xchange" target="tclxchange" class="extern" href="http://www.tcl.tk/"> |
| The Tcl/Tk Language |
| </a> |
| </li> |
| <li class="navitem"> |
| <a title="Tcl community wiki site" target="tclwiki" class="extern" href="http://wiki.tcl.tk/">Tcl'ers Wiki</a> |
| </li> |
| </ul> |
| </li> |
| <li id="manual"> |
| <h4>Rivet Documentation</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a title="Rivet 2.1 Manual" target="rivetman2.1" href="http://tcl.apache.org/rivet/manual2.1/">Rivet 2.1</a> |
| </li> |
| <li class="navitem"> |
| <a title="Rivet 2.2 Manual" target="rivetman2.2" href="http://tcl.apache.org/rivet/manual2.2/">Rivet 2.2</a> |
| </li> |
| <li class="navitem"> |
| <a title="Rivet 2.3 Manual" target="rivetman2.3" href="http://tcl.apache.org/rivet/manual2.3/">Rivet 2.3</a> |
| </li> |
| <li class="navitem"> |
| <a title="Rivet 3.0 Manual" target="rivetman3.0" href="http://tcl.apache.org/rivet/manual3.0/">Rivet 3.0</a> |
| </li> |
| </ul> |
| </li> |
| <li id="support"> |
| <h4>Support</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a title="Apache Rivet Bugzilla" class="extern" href="https://issues.apache.org/bugzilla/buglist.cgi?quicksearch=Rivet">Bug Reports</a> |
| </li> |
| </ul> |
| </li> |
| |
| </ul> |
| <ul> |
| <li id="acknowledgments"> |
| <h4>Acknowledgments</h4> |
| <ul class="blocklist"> |
| <li class="navitem"> |
| <a href="http://www.apache.org/foundation/thanks.html">ASF Sponsorship</a> |
| </li> |
| </ul> |
| </li> |
| |
| </ul> |
| </div> |
| <div class="clear"></div> |
| </div> |
| </div> |
| <div id="footer"> |
| <div class="footer-content"> |
| <p><a href="http://www.apache.org/">Apache Software Foundation</a> | Design by <a href="http://www.spyka.net">Free CSS Templates</a> | <a href="http://www.justfreetemplates.com">Free Web Templates</a></p> |
| </div> |
| </div> |
| <div style="text-align: center; font-size: 0.75em;">Design downloaded from <a href="http://www.freewebtemplates.com/">free website templates</a>.</div></body> |
| </html> |
| |