Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

basic Tcl -- printing a value of variable

Tags:

set

puts

tcl

I have the following script in Tcl:

set val(a) 10
set val(b) 10
set val(n) expr{$val(a) * $val(b)}

How to print the value of the variable n?

puts $val(n)

gives expr{10*10} and i need to see 100....

like image 803
user2009590 Avatar asked Oct 28 '25 08:10

user2009590


1 Answers

In order to evaluate an expression and return the results, you must put the eval command inside square brackets, rather than try to call it like a function:

set val(n) [expr {$val(a) * $val(b)}]
puts $val(n)
like image 139
Bryan Oakley Avatar answered Oct 31 '25 11:10

Bryan Oakley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!