Showing results for 
Search instead for 
Do you mean 
Reply

TCL array with global key

I am trying to acces a tcl array with a key which is a global variable. Postbuilder won't save such a construction. If I modify this in the tcl file itself the post works just fine. This post also opens without problem, but it won't save. I do see similar constructions though. Procedures LOCK_AXIS and UNLOCK_AXIS are using it.

 

I am using mom_tool_designation but it can be any global variable. A very simple example:

global mom_tool_designation
array set myarray {foo bar}

MOM_output_literal $myarray($mom_tool_designation)

And mom_tool_designation should exist and be "foo" of course to see something. But this is not postbuilders business. I understand that the above construction will get me into trouble if I don't check anything before using it. 

W10 NX11.0.1
4 REPLIES

Re: TCL array with global key

I would quote the output:

 

MOM_output_literal "$myarray($mom_tool_designation)"

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: TCL array with global key

The MOM_output_literal was not the problem. But I tried the quotes anyway, didn't help. What did solve the problem was making some if else statements holding one solution without the key as a global var in it. 

 

Still don't understand why that does work though. 

W10 NX11.0.1

Re: TCL array with global key

That's why almost all my tcl code is in an external (sourced in) tcl file.

 

Almost all my custom commands in the post look like:

PB_CMD_Moog_Do_XYZ { } {
# This does XYZ
# put it is these events:  ...
      Moog_Do_XYZ ;# Call external proc.
}

 

Postbuilder parser stays happy.

Of course, now I have to actually run the post to find all the "dumb programmer tricks", instead of having them found in PB.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: TCL array with global key


Ken_A wrote:

That's why almost all my tcl code is in an external (sourced in) tcl file.


 

Agreed, although I would prefer not to put things in an external file. Just to have everything in one place. 

W10 NX11.0.1

Learn online





Solution Information