Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array problem again 1

Status
Not open for further replies.

87106

Programmer
Oct 11, 2006
2
US
I have a simple code like this. I'm new to tcl/tk world.

This works:
change v array_1[0] 10

But this doesn’t work:
set x 1
change v array_1[$x] 10

Note : array_10[20] is an array C langauge array.

Basically I want to change the value of an array. Why it works when i pass absolute value as an index & not when I pass index indirectly.

Please help!
 
I think you must be mixing languages here.
change is not a Tcl statement that I recognize. Furthermore, arrays in Tcl are indexed with regular parentheses, (), not square brackets, [].

Now, in Tcl you change an element of an array simply by seting it: set array_1($x) 10, for instance.

_________________
Bob Rashkin
 
Thanks Bob. Indeed I was mixing up the langauges. I'm using Codewarrior IDE tcl shell. So "change value" was IDE provided command. Thanks for directing me to use "set" instead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top