Tcl: Tcl Command Execute by Variable

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.

3

2 Answers

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.

1

Just add eval while calling the command.

set path0001 [eval $var]

Reference : eval

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.