Reputation: 1778
I'm using Foundry Nuke and try to work with tcl command.
I have this code :
[lindex [split "xx_cc" "_"] 0]
If I put this code into a text node. I will output the correct result which is 'xx'
But in this case I put the code in the project setting (root) as a string . I added a new knob (named as 'cxproject' and type is text input knob). Then put the code in this knob ( as string)
Then in the a text node , I put this code :
[value root.cxproject]
Trying to load the code and evaluate that string to be executed as tcl command.
The result is the original string of the code itself -> [lindex [split "xx_cc" "_"] 0] . This is not what I want. I want to see the result as 'xx'.
I tried :
[eval [value root.cxproject] ]
but not working.
How to evaluate a string as tcl command using tcl script ?
Upvotes: 0
Views: 145
Reputation: 1873
Using eval $string
is exactly what you should do.
Can you please share exactly what [value root.cxproject]
returns?
It might be possible that you have too many square brackets.
For example:
eval {expr 1+1}
will return 2.
but eval [expr 1+1]
will yield the error message invalid command name "2"
Upvotes: 0