Amir Rachum
Amir Rachum

Reputation: 79645

Invalid command name in Tcl when using format

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?

Upvotes: 4

Views: 2911

Answers (5)

Roalt
Roalt

Reputation: 8440

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

Upvotes: 0

Trey Jackson
Trey Jackson

Reputation: 74430

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.

Upvotes: 3

Hai Vu
Hai Vu

Reputation: 40733

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.

Upvotes: 3

jk.
jk.

Reputation: 14004

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

Upvotes: 0

kostix
kostix

Reputation: 55473

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
%

Upvotes: 1

Related Questions