Braindead:: Testing against backticks (expressions)

   4849   5   0
User Avatar
Member
12433 posts
Joined: July 2005
Offline
Hi all,

If I want to detect whether a parameter has an expression in it or not, how can I do it? i.e. I want to detect whether a string has a backtick in it::

My string has this in it.

/obj/geo1/file1/filename geo.`padzero(4,$F+32)`.bgeo


And I'm trying to do this:

set valueraw = `chsraw(“/obj/geo1/file1/filename”)`
if( `index($valueraw, “\`” )` > -1 )
echo “This has an expression in it.”
endif


My backslashes print as Yen, for some reason \\

For some reason, no combination of escaping this backtick seems to work. Help me, anyone?

Thanks,
Jason
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
398 posts
Joined: July 2005
Offline
Jason, catch it!
http://www.aviajournal.interami.com/tmp/check_expr.hipnc [aviajournal.interami.com]

P.S. Houdini, Houdini… Where is my Perl-like regexps?
f = conserve . diffuse . advect . add

fx td @ the mill
User Avatar
Member
941 posts
Joined: July 2005
Offline
jason_iversen
For some reason, no combination of escaping this backtick seems to work. Help me, anyone?

Hi Jason,

There's a little trick I use all the time for csh scripts, which seems to work in this case too. Just assign the back-tick to a tmp variable and use the variable in the search statement. That way it is not part of the initial expansion of the expression…. like this:


set tick = `
if( `index(chsraw(“/obj/geo1/file1/filename”), $tick)` > -1 )
echo “This has an expression in it.”
endif


Hope that helps,

Cheers!
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
12433 posts
Joined: July 2005
Offline
Hi Mario,

I did try that yesterday, with no luck. It seemed to screw up when it expands the variable. Did this code fragment work for you?

add: In fact, I've tried all manner of trying to put the entire expression into a variable and running eval() on it. It seems to want to choke anytime your use the backticks to get the result of an expression which contains backticks in it.


Thanks,
Jason

..

Hi hohnamahn,

Thanks for your help; it seems like there should be a silghtly simpler solution. I'll see what I can do with yours.

add: It seems work if it just do this:


float CheckExpr(string path) {
return index(path,'`')>-1;
}


..since all I want to do is check whether there are backticks in the expression. A little complicated, but there must be some voodoo going on with escaped (unbalanced) backticks in hscript.

Thank you,
Jason
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
941 posts
Joined: July 2005
Offline
jason_iversen
Hi Mario,

I did try that yesterday, with no luck. It seemed to screw up when it expands the variable. Did this code fragment work for you?

Hmmmm…strange.
Yes, I tried it and it worked OK (H6.1.371, Linux RH7.3)

My little test went like this:

*) Default scene. Toggled auto-gen reflection map on /obj/geo1 and set it to the expression /tmp/test.`padzero(4,$F)`.rat
*) Opened textport and here's what happened:

/ -> opcf /obj

/obj -> echo `chsraw(“geo1/reflmap”)`
/tmp/test.`padzero(4,$F)`.rat


/obj -> set tick = `
/obj -> echo `index(chsraw(“geo1/reflmap”),$tick)`
10

/obj -> if (`index(chsraw(“geo1/reflmap”),$tick)` > -1 )
/obj -> echo “This has an expression in it.”
This has an expression in it.
/obj -> endif


Which lead me to believe that it worked, although it's not the *exact* same test as yours… so let me try yours…

*) Added a file sop inside geo1 with an expression string for the file name
*) And here's the textport dump, continued from before:
/obj -> echo `chsraw(“geo1/file1/file”)`
/tmp/test.`padzero(4,$F)`.bgeo

/obj -> if(`index(chsraw(“geo1/file1/file”),$tick)`>=0)
/obj -> echo “This has an expression in it.”
This has an expression in it.
/obj -> endif
/obj ->


So it *seems* to work…
Could it be a version/environment thing?
Mario Marengo
Senior Developer at Folks VFX [folksvfx.com] in Toronto, Canada.
User Avatar
Member
12433 posts
Joined: July 2005
Offline
I wonder.. I'm on Houdini 6.5.71 on RH9.

Thanks for checking it out..

Oh wow; it works very (erratically) for me now; after several false starts. I think its hanging on by a thread. (like all my scripting)

Thanks Mario! I appreciate your and hoknaham's help.

Take care,
J
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
  • Quick Links