Difference between revisions of "AOLserver and Tcl Crash Course"

From AOLserver Wiki
Jump to navigation Jump to search
(Added hello world example)
Line 4: Line 4:
 
** Hello <Yourname> - Simple page, user submits form, displays name
 
** Hello <Yourname> - Simple page, user submits form, displays name
 
*** DOSSY: Create this example with very simple Tcl.
 
*** DOSSY: Create this example with very simple Tcl.
** Tcl Basics
+
 
*** Explain Minimalist Syntax
+
 
**** Commands, Subcommands (Evaluated and Non-Evaluated)
+
  # hello-world.tcl
**** Working with variables set, expr
+
  set form [ns_getform]
*** Control Structures
+
  set name [string trim [ns_set get $form name]]
**** if, while, etc.
+
  if {$name eq ""} {
**** procedures
+
      set name "world"
** Fetching GET and POST
+
  }
 +
  ns_return 200 text/html "<html>
 +
      <head><title>Hello [ns_quotehtml $name]!</title></head>
 +
      <body>
 +
      Hello [ns_quotehtml $name]!
 +
      <form action='hello-world.tcl' method='post'>
 +
      Name: <input name='name' value='[ns_quotehtml $name]'>
 +
      <input type='submit'>
 +
      </form>
 +
      </body>
 +
      </html>"
 +
 
 +
 
 +
* Tcl Basics
 +
** Explain Minimalist Syntax
 +
*** Commands, Subcommands (Evaluated and Non-Evaluated)
 +
*** Working with variables set, expr
 +
** Control Structures
 +
*** if, while, etc.
 +
*** procedures
 +
* Fetching GET and POST
 
** Including / Referring to other pages
 
** Including / Referring to other pages
 
** Controlling Output
 
** Controlling Output
Line 24: Line 44:
 
* How can one use Tcl to write very concise and readable code?
 
* How can one use Tcl to write very concise and readable code?
 
* How does one efficiently separate pages into MVC components if the wanted?
 
* How does one efficiently separate pages into MVC components if the wanted?
 +
* How and why should one write a domain specific sublanguage?

Revision as of 21:20, 15 June 2007

Draft Outline

  • ADP Pages
    • Hello <Yourname> - Simple page, user submits form, displays name
      • DOSSY: Create this example with very simple Tcl.


  # hello-world.tcl
  set form [ns_getform]
  set name [string trim [ns_set get $form name]]
  if {$name eq ""} {
      set name "world"
  }
  ns_return 200 text/html "<html>
      <head><title>Hello [ns_quotehtml $name]!</title></head>
      <body>
      Hello [ns_quotehtml $name]!
      <form action='hello-world.tcl' method='post'>
      Name: <input name='name' value='[ns_quotehtml $name]'>
      <input type='submit'>
      </form>
      </body>
      </html>"


  • Tcl Basics
    • Explain Minimalist Syntax
      • Commands, Subcommands (Evaluated and Non-Evaluated)
      • Working with variables set, expr
    • Control Structures
      • if, while, etc.
      • procedures
  • Fetching GET and POST
    • Including / Referring to other pages
    • Controlling Output
    • Databases
      • Defining the connection from as a pool in the config.tcl
      • Selecting from the pool
      • Executing Queries, Retrieving Values

Questions

  • Where does ADP excel?
  • What practices should PHP, ASP, JSP developers stop doing?
  • How can one use Tcl to write very concise and readable code?
  • How does one efficiently separate pages into MVC components if the wanted?
  • How and why should one write a domain specific sublanguage?