You can use lindex
:
set my_list [list word0 word1 word2 word3]
set test [lindex $my_list 0]
puts $test
# => word0
In Tcl, the first element in a list has the index 0.
Question
I have a list in TCL:
{word0} {word1} {word2} {word3}
I need to set a new string to one of the values in the list. What would the syntax be for that?
set test {$my_list 0}
set test [$my_list 0]
Neither work.
Sorry for the new question, but I'm not familiar with this syntax and not finding it in the docs.
La solution
You can use lindex
:
set my_list [list word0 word1 word2 word3]
set test [lindex $my_list 0]
puts $test
# => word0
In Tcl, the first element in a list has the index 0.