simple parsing syntax error

   4311   6   1
User Avatar
Member
897 posts
Joined: July 2018
Offline
why do I get an error here?
/ -> set foo = `opget -l “/obj/geo/file1”`
Expression error: Syntax error - extra tokens detected in expression

When this works?
/ -> opget -l /obj/geo/file1
opset -l off /obj/geo/file1


shouldn't $foo be set to “opset -l off /obj/geo/file1”?
B.Henriksson, DICE
User Avatar
Member
8555 posts
Joined: July 2007
Offline
why not just
/ -> set foo = opget -l /obj/geo/file1
?
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
897 posts
Joined: July 2018
Offline
hey tamte
Because I want what's returned from the opget function, not the command that executes it:

/ -> set foo = opget -l /obj/geo1/file1
/ -> echo $foo
opget -l /obj/geo1/file1


the `opget` function returns a `opset` command and this is what I want to store in the variable. (what I originally needed is to query the lock state on an operator but then I ran into this thing)

Thx!
B.Henriksson, DICE
User Avatar
Member
7721 posts
Joined: July 2005
Online
When using backticks, it is in the expression language whereas the opget command is in the command language. To run something in the command language within backticks, you need to use the run() expression.

set foo=`run('opget -l “/obj/geo/file1”')`
User Avatar
Member
897 posts
Joined: July 2018
Offline
Ahhh, I suspected I was missing something fundamental here. Thanks!

Just of curiousity, this seems like a pretty weird solution, is this how you would aproach the problem of unlocking a node? -getting the opset command and then extract whether or not the lock is on?
B.Henriksson, DICE
User Avatar
Member
7721 posts
Joined: July 2005
Online
It is awkward in hscript. That's why I'd use something like is_locked = node.isSoftLocked() || node.isHardLocked() in python.
User Avatar
Member
897 posts
Joined: July 2018
Offline
thx again. I started in python actually but couldn't find the command for it.
B.Henriksson, DICE
  • Quick Links