====== Getting started with Tcl: example 5 ====== This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]] ===== Using arrays, for, foreach ===== ==== Script ==== #!/usr/bin/tclsh # Using arrays, for, foreach set tableau(1) un set tableau(2) deux set tableau(3) trois for {set i 1} { $i <= 3 } {incr i} { puts stdout "tableau($i) = $tableau($i)" } puts stdout "" set tableau(tcl) {c'est super} set tableau(fleur) {la rose} foreach index [array names tableau] { puts stdout "tableau($index) = $tableau($index)" } ==== Output ==== tableau(1) = un tableau(2) = deux tableau(3) = trois tableau(1) = un tableau(fleur) = la rose tableau(2) = deux tableau(tcl) = c'est super tableau(3) = trois
---- This page is part of the Airplug documentation related to Tcl/Tk.\\ [[en:doc:pub:tcltk:start|Back to the Tcl/Tk documentation page]] / [[en:doc:summary|Back to the Airplug documentation page]]