chingwei
chingwei

Reputation: 13

TCL: tcl command execute by variable

I am a beginner with tcl. I am trying to use primetime execute command, but it can't accept variable. For example:

set var "get_timing_paths -rise_from A -rise_to B"
set path0001 [$var]

But it doesn't work. The things I want to do is

set path0001 [get_timing_paths -rise_from A -rise_to B]

but I need to seperate it.

Thank you for your answer.

Upvotes: 1

Views: 3039

Answers (2)

Sergei Golovan
Sergei Golovan

Reputation: 611

If you're using Tcl/Tk 8.5 or newer, it'd be better to use the list expansion operator {*} instead of eval:

set var "get_timing_paths -rise_from A -rise_to B"
set path0001 [{*}$var]

It's a bit faster and safer.

Upvotes: 5

Dinesh
Dinesh

Reputation: 16428

Just add eval while calling the command.

set path0001 [eval $var]

Reference : eval

Upvotes: 0

Related Questions