Tcl: Difference between revisions
(New page: All of FLOODS/FLOOPS is built using tcl. A familiarity with tcl commands is essential for understanding how to do anything complex in FLOOPS and FLOODS. You can find many great tcl refer...) |
No edit summary |
||
Line 1: | Line 1: | ||
All of FLOODS/FLOOPS is built using tcl. A familiarity with tcl commands is essential for understanding how to do anything complex in | All of FLOODS/FLOOPS is built using tcl. A familiarity with tcl commands is essential for understanding how to do anything complex in FLOOXS. You can find many great tcl reference books. We suggest ''Practical Programming in Tcl and Tk'' by Brent Welch and Ken Jones. [http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm tcl command documentation] is also available. Below are some common tcl commands and how to use them. | ||
= Common Tcl Commands = | |||
==== set ==== | |||
The "set" command is used to set variables. The syntax is | |||
set ''variable_name'' ''value'' | |||
All of the variables in tcl are strings. Thus, in the example below, all the variables var1-var5 are strings. | |||
set var1 bunchofletters | |||
set var2 1e5 | |||
set var3 1.0e5 | |||
set var4 1.0 | |||
set var5 1+2 | |||
If you type these on the flooxs command line, you'll see that you get back exactly the string of characters you gave. Notice that "1+2" is not evaluated; it is simply a string of 3 characters, the first of which is the character "1", the second of which is the character "+", and the third of which is the character "2". | |||
==== expr ==== | |||
Since all variables in tcl are strings, we need a way of doing math. This is the "expr" command, which stands for "mathematical '''expr'''ession" | |||
==== puts ==== | |||
==== string ==== | |||
==== list ==== | |||
==== file ==== | |||
= Stuff to Watch out For = | |||
==== brackets in comments ==== | |||
==== eval set ==== |
Revision as of 22:53, 30 March 2011
All of FLOODS/FLOOPS is built using tcl. A familiarity with tcl commands is essential for understanding how to do anything complex in FLOOXS. You can find many great tcl reference books. We suggest Practical Programming in Tcl and Tk by Brent Welch and Ken Jones. tcl command documentation is also available. Below are some common tcl commands and how to use them.
Common Tcl Commands
set
The "set" command is used to set variables. The syntax is
set variable_name value
All of the variables in tcl are strings. Thus, in the example below, all the variables var1-var5 are strings.
set var1 bunchofletters set var2 1e5 set var3 1.0e5 set var4 1.0 set var5 1+2
If you type these on the flooxs command line, you'll see that you get back exactly the string of characters you gave. Notice that "1+2" is not evaluated; it is simply a string of 3 characters, the first of which is the character "1", the second of which is the character "+", and the third of which is the character "2".
expr
Since all variables in tcl are strings, we need a way of doing math. This is the "expr" command, which stands for "mathematical expression"