Tcl : foreach command

Foreach command used to execute tcl scripts for every element of one or more lists. The basic syntax is below :

foreach varname list script

To iterate on a list and show element value on screen :

Foreach with two variables :

Foreach with two lists and two variables for each list :

Thats how we can use foreach command in Tcl. It is flexible.

Leave a Reply

Your email address will not be published. Required fields are marked *