~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
set x 0
# this will loop for ever
-# because while argument is ;0 3;
-while ;$x 3; {set x [expr $x+1]}
+# because while argument is ;0 < 3;
+while ;$x < 3; {set x [expr $x+1]}
# this will terminate as expected because
-# while argument is {$x 3}
-while {$x 3} {set x [expr $x+1]}
+# while argument is {$x < 3}
+while {$x < 3} {set x [expr $x+1]}
# this can be written also
-while {$x 3} {
+while {$x < 3} {
set x [expr $x+1]
}
# the following cannot be written
# because while requires two arguments
-while {$x 3}
+while {$x < 3}
{
set x [expr $x+1]
}
**Example:**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
-if {$x 0} {
+if {$x > 0} {
puts ;positive;
} elseif {$x == 0} {
puts ;null;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
# while example
dset x 1.1
-while {[dval x] 100} {
+while {[dval x] < 100} {
circle c 0 0 x
dset x x*x
}
# for example
# incr var d, increments a variable of d (default 1)
-for {set i 0} {$i 10} {incr i} {
+for {set i 0} {$i < 10} {incr i} {
dset angle $i*pi/10
point p$i cos(angle0 sin(angle) 0
}
**Example:**
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
# search the index for which t$i has value ;secret;
-for {set i 1} {$i = 100} {incr i} {
+for {set i 1} {$i <= 100} {incr i} {
if {[set t$i] == ;secret;} break;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Not OK. display points on a curve c
# with dot no variables are created
-for {set i 0} {$i = 10} {incr i} {
+for {set i 0} {$i <= 10} {incr i} {
cvalue c $i/10 x y z
point . x y z
}
[-arrow external|internal|fit] [{-arrowlength|-arlen} RealArrowLength]
[{-arrowangle|-arangle} ArrowAngle(degrees)] [-plane xoy|yoz|zox]
[-flyout FloatValue -extension FloatValue]
- [-autovalue] [-value CustomRealValue] [-textvalue CustomTextValue]
+ [-autovalue] [-value CustomRealValue] [-textvalue CustomTextValue]
[-dispunits DisplayUnitsString]
[-modelunits ModelUnitsString] [-showunits | -hideunits]
~~~~~
~~~~~
InitChildNodeIterate D 0:5 1
set aChildNumber 0
-for {set i 1} {$i 100} {incr i} {
+for {set i 1} {$i < 100} {incr i} {
if {[ChildNodeMore] == *TRUE*} {
puts *Tree node = [ChildNodeValue]*
incr aChildNumber
**Example:**
~~~~~
-# make a helix of circles. create a scripte file with
+# make a helix of circles. create a script file with
this code and execute it using **source**.
circle c0 10 0 0 3
-for {set i 1} {$i = 10} {incr i} {
+for {set i 1} {$i <= 10} {incr i} {
copy c[expr $i-1] c$i
translate c$i 0 0 3
rotate c$i 0 0 0 0 0 1 36
~~~~~
# display points on a sphere
sphere s 10
-for {dset t 0} {[dval t] = 1} {dset t t+0.01} {
+for {dset t 0} {[dval t] <= 1} {dset t t+0.01} {
svalue s t*2*pi t*pi-pi/2 x y z
point . x y z
}
# make rotated copies of a sphere in between two cylinders
# create a file source toto.tcl
# toto.tcl code:
-for {set i 0} {$i 360} {incr i 20} {
+for {set i 0} {$i < 360} {incr i 20} {
copy s s$i
trotate s$i 0 0 0 0 0 1 $i
}