TCL within and without Houdini

   6210   10   1
User Avatar
Member
12 posts
Joined: July 2005
Offline
Hello everyone, this is my first post.

I am teaching myself HScript and I am writing a script using TCL and HScript. I have two questions:
1) When using TCL outside of Houdini, I am able to run the follwing line of code with no problems:

string first $token $stringToParse $index

When I do this within Houdini, I get the following error:

>>wrong # args: should be “string first string1 string2”

Does anyone know why this is or how I can get around it?

2) The second question that when I pass a string from TCL to HScript, I get curly brackets around the string. How can I avoid this?

When I run:
set lightName “keyLight”
set temp “c (0 1 0)”
hscript opparm $lightName -v $temp

I get the error:
>>Skipping unrecognized parameter “{c”
>>Skipping unrecognized parameter “(”
>>Skipping unrecognized parameter “0”
>>Skipping unrecognized parameter “1”
>>Skipping unrecognized parameter “1”
>>Skipping unrecognized parameter “)”

I've figure out that it's because in hscript, $temp becomes { c (0 1 0)}. I tried doing some string manipulations to remove the brackets. It works in hscript, but if I do those same string manipulations from TCl, it does not work.

Any help would be appreciated. Thank you.
User Avatar
Member
12 posts
Joined: July 2005
Offline
Okay I solved problem number 2 by simply rewriting the statement as:
hscript opparm $lightName -v “ $temp ”

instead of hscript opparm $lightName -v $temp

I also tried hscript opparm $lightName -v “$temp” but that does not work either.


I still need help with problem #1 if anyone knows how to solve it.
Thanks
User Avatar
Member
7734 posts
Joined: July 2005
Offline
What Tcl procedure are you trying to use? Keep in mind that Houdini is embedded with a relatively old verson of Tcl/Tk, 8.0p2. Perhaps the procedure that you're using has since been changed.
User Avatar
Member
7025 posts
Joined: July 2005
Offline
I used to like TCL, but the curly braces make it a nightmare with Houdini, you get them all the time and have to jump through all sorts of hoops to get rid of them.

I'm growing to like Perl, despite it's often bizarre syntax, because it allows you to define characters to use as quote delimiters, and it has really good Regex support.

You can tie Perl into Houdini using the “openport” Textport command combined with the “hcommand” command-line tools.

Cheers,

Peter B
User Avatar
Member
7734 posts
Joined: July 2005
Offline
Bah, Ruby is the one true scripting language now.
User Avatar
Member
4140 posts
Joined: July 2005
Offline
…JC loads his Python Blunderbuss…

J.C.
John Coldrick
User Avatar
Member
12 posts
Joined: July 2005
Offline
edward, I am not trying to run a procedure. I had a string that I was trying to parse based on a token. So, if I create myString, then try to do something like , I get the error.
Basically, Houdini is telling me the syntax is wrong - it doesn't like the $index part - but that is the correct syntax according to tcl.tk and every other place I have checked.
User Avatar
Member
7734 posts
Joined: July 2005
Offline
“string” is just a built-in tcl procedure. I've confirmed that it is a tcl/tk version number difference. Compare the documentation for string first in tcl/tk 8.0:
http://www.tcl.tk/man/tcl8.0/TclCmd/string.htm#M6 [tcl.tk]
with the same thing in 8.2.3:
http://www.tcl.tk/man/tcl8.2.3/TclCmd/string.htm#M8 [tcl.tk]

Basically, at some point after tcl/tk 8.0, they added that option start index argument.
User Avatar
Member
12 posts
Joined: July 2005
Offline
Oh Ok. Thank you Edward, that helps a lot.

Does anyone know if the version of TCL used by Houdini can be changed?
User Avatar
Member
7734 posts
Joined: July 2005
Offline
No, that can't be changed. This problem is easy enough to workaround anyhow by extracting the substring you want to search first.
User Avatar
Member
12 posts
Joined: July 2005
Offline
I worked around it by using
string last string1 string2 instead. Then I run that on tha substring up until the returned index. So I parse from right to left instead of left to right.
  • Quick Links