TCL:tcl 命令按变量执行

1 variables command tcl

我是 tcl 的初学者。我正在尝试使用 primetime execute 命令,但它不能接受变量。例如:

set var "get_timing_paths -rise_from A -rise_to B"
set path0001 [$var]
Run Code Online (Sandbox Code Playgroud)

但它不起作用。我想做的事情是

set path0001 [get_timing_paths -rise_from A -rise_to B]
Run Code Online (Sandbox Code Playgroud)

但我需要把它分开。

谢谢您的回答。

小智 5

如果您使用 Tcl/Tk 8.5 或更新版本,最好使用列表扩展运算符{*}而不是eval

set var "get_timing_paths -rise_from A -rise_to B"
set path0001 [{*}$var]
Run Code Online (Sandbox Code Playgroud)

它更快更安全。