The reason this doesn’t work is Nuke’s expression parser doesn’t deal with
strings. As soon as you throw the brackets in there, you’re invoking the
full-on TCL interpreter to run that part of it, but you’re still trying to
compare the result of that command (which will probably be 0) to a string in
Nuke’s expression parser (which is invalid).
To actually compare the strings, move the whole comparison into TCL land:
[string match [getenv USER] "Steve"] ? 0 : 1
The “string match” function will return 1 if the strings match and 0 otherwise.
Hope this helps,
-Nathan
From: Xavier Bourque
Sent: Wednesday, August 03, 2011 2:39 AM
To: Nuke user discussion
Subject: [Nuke-users] Evaluating a string in Nuke expressions?
Hi,
I'm trying to setup a switch that turns on and off depending on the value of a
shell environment variable.
I can access the variable using getenv or $env, but I'm not sure how to
evaluate strings in Nuke's expressions.
For instance, if I want to evaluate in a switch node if the current user name
is "xavierb", I expected one of these to work:
$env(USER) == "xavierb" ? 0 : 1
[getenv USER] == "xavierb" ? 0 : 1
In both cases I get an error.
How can you evaluate strings inside Nuke nodes?
Thanks for any tips!
--Xavier
--------------------------------------------------------------------------------
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users