cheesewendy
cheesewendy

Reputation: 1

Using variable in array of Tcl

I create a variable called delay

set delay [expr ($max-$min)];

I want to use it in a array like:

set_value/$env(sim_name)/taps  {{0,0,$delay,0,0}}; #double[5]

But brace will stop to substitution the value of delay, right?

The fault said is invalid_float or zero element array.

what could I do?

Upvotes: 0

Views: 448

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385810

The outermost braces are for quoting. A good rule for quoting is to use what works. In other words, don't use curly braces if you don't want the behavior of curly braces. If you need to have variables expanded, use double quotes:

set_value/$env(sim_name)/taps "{0,0,$delay,0,0}"

There's likely another thing wrong with your example. You're calling a command named "set_value/$env(sim_name)/taps", which is a rather unusual looking command name. Are you certain that's what you want to do?

Upvotes: 1

Related Questions