Jonathan Booth Copyleft 1996, Intersession '96 Jonathan Booth -- The Tcl Language -- -- Instructor's Notes -- Method is as follows: 1. Get everyone into tclsh on the servers 2. Variables A. Types of variables a. numeric (integer) b. floating point c. char d. string e. following can use any of above 1. list (only one type of data) 2. array (mix of data types, mix of references to it) B. Setting of variables a. % set x 5 b. % set y(me) "Jonathan Booth" c. % set y($x) "Not $y(me)" d. % set list [0,1,2,3,4,5,6,7,8,9] e. % set colors ["red","yellow","green","blue"] C. Referencing of variables 3. Operators A. How operators are used on variables B. Explain [expr ] a. % set c [expr a + b] b. % set d [expr [expr a + b] + c] 4. Looping A. Why want to use a. who wants to type the code n times over? b. faster than n times of procedure calls 1. % doit;doit;doit B. How use a. % if {condition} {body} b. % while {condition} {body} c. % for {init} {test} {action 1} {body} d. % foreach var_name {} {body} e. % switch {var} {body} 5. Procedures A. Why want to use a. 2 ops that need to do 1 thing can call a procedure B. How use a. % proc proc_name {args} {body} b. % proc_name 6. Other Commands A. User-IO a. % puts stdout "message" b. % set value [gets stdin] c. more info? man puts & gets B. File-IO a. % set file [open "foo.txt"] ... % close file ... b. man open, go from there. File ops can be complex, and I'm not going to make you do them. 7. Assignment A. If have a project in mind, you can do it if you like Just give a short write up in comments at the start of it. B. Else, take this problem sheet and work on it. It starts easy, and graduates harder. Start where you feel comfortable (or I direct you to). 8. Debug, debug, debug...