使用格式时 Tcl 中的命令名称无效

发布于 2024-11-13 11:48:37 字数 317 浏览 2 评论 0原文

我正在运行以下命令

set full_pin_name [format "%s %s" $top_cell $encoded_name]
puts "full_pin_name is $full_pin_name"

,但收到以下错误:

full_pin_name is invalid command name "A" B

top_cell 等于 A 且 encoded_name 等于 B 时。
为什么会发生这种情况?

I'm running the following commands

set full_pin_name [format "%s %s" $top_cell $encoded_name]
puts "full_pin_name is $full_pin_name"

and I get the following error:

full_pin_name is invalid command name "A" B

when top_cell equals A and encoded_name equals B.
Why is this happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

能怎样 2024-11-20 11:48:37

我怀疑问题出在您的 $top_cell 变量上,该变量的值为无效的命令名称“A”。要进行检查,请在格式行之前尝试以下行:

puts ">$top_cell<"

如果 $top_cell 值确实有问题,则可以追溯到最后一个 set 命令。请告诉我们它是否可以解决您的问题,否则我们可能会尝试其他方法。

I suspect the problem is with your $top_cell variable, which has the value invalid command name "A". To check, try the following line before your format line:

puts ">$top_cell<"

If indeed, $top_cell value has a problem, you can then trace back to the last set command. Let us know if it fixes your problem, or we might try some other approaches.

冷血 2024-11-20 11:48:37

尝试在普通的 Tcl shell 中重复此操作,它可以工作。您的 Tcl shell 中有些东西不同。

尝试

info body set

一下,

info body format

如果报告除 set isn't a procedureformat isn't a procedure 以外的内容,那么您就找到了罪魁祸首。

Try repeating this in a plain Tcl shell, it works. Something is different in your Tcl shell.

Try

info body set

and

info body format

If either report something other than set isn't a procedure or format isn't a procedure then you have your culprit.

迷乱花海 2024-11-20 11:48:37

这段代码可能运行在定义了 set 命令的命名空间中吗?
演示:

% namespace eval foo {
    proc set args {
      puts hey!
    }
    proc whatever {top_cell encoded_name} {
      set full_pin_name [format "%s %s" $top_cell $encoded_name]
      puts "full_pin_name is $full_pin_name"
    }
  }
% ::foo::whatever A B
hey!
can't read "full_pin_name": no such variable
%

May be this code runs in a namespace which has the set command defined in it?
To demonstrate:

% namespace eval foo {
    proc set args {
      puts hey!
    }
    proc whatever {top_cell encoded_name} {
      set full_pin_name [format "%s %s" $top_cell $encoded_name]
      puts "full_pin_name is $full_pin_name"
    }
  }
% ::foo::whatever A B
hey!
can't read "full_pin_name": no such variable
%
辞旧 2024-11-20 11:48:37

据我所知,这里没有 TCL 解释器,假设有定义格式的普通解释器应该可以工作。所以看起来格式可能已被重命名或者在您使用的解释器中不作为命令存在?

为了让你继续前进,你实际上并不需要格式来连接字符串,无论如何

设置 fill_pin_name "$top_cell $encoded_name"

应该是你所需要的

As far as I can tell without a TCL interpreter here it should work assuming a normal interpreter with format defined. so it looks like maybe format has been renamed or doesn't exist as a command in the interpreter you are using?

To get you going you don't really need format to join strings anyway

set fill_pin_name "$top_cell $encoded_name"

should so what you need

忱杏 2024-11-20 11:48:37

也许您的代码如下所示:

set encoded_name B  
if { [catch {[A]} top_cell]} {
    set full_pin_name [format "%s %s" $top_cell $encoded_name]
    puts "full_pin_name is $full_pin_name"
}

结果是:

full_pin_name is invalid command name "A" B

Maybe your code looks like this:

set encoded_name B  
if { [catch {[A]} top_cell]} {
    set full_pin_name [format "%s %s" $top_cell $encoded_name]
    puts "full_pin_name is $full_pin_name"
}

The result is:

full_pin_name is invalid command name "A" B
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文