Invalid command name in Tcl when using format

I run 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 is A and encoded_name is B.
Why is this happening?

+4
source share
5 answers

I suspect that the problem is related to the variable $ top_cell, which has an invalid command name "A" . To check, try the following line before the format line:

 puts ">$top_cell<" 

If $ top_cell really matters, you can return to the last set command. Let us know if your problem fixes, or we can try other approaches.

+3
source

Try to repeat this in a simple Tcl shell, it works. Something else in your Tcl shell.

Try

 info body set 

and

 info body format 

If you are reporting something other than set isn't a procedure or format isn't a procedure , then you have your culprit.

+3
source

Can this code run in the namespace in which the set command is defined? 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 AB hey! can't read "full_pin_name": no such variable % 
+1
source

As far as I can tell without the TCL interpreter here, it should work assuming a normal interpreter with a specific format. so it looks like the format has been renamed or does not exist as a command in the interpreter you are using?

Whatever you do, you really don't need a format for concatenating strings anyway

set fill_pin_name "$ top_cell $ encoded_name"

should so you need

0
source

Perhaps 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" } 

Result:

 full_pin_name is invalid command name "A" B 
0
source