| <!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_download.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> |
| |
| </ul> |
| <ul> |
| |
| </ul> |
| <ul> |
| |
| </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> |
| |