if - syntax error

   2595   1   2
User Avatar
Member
58 posts
Joined: July 2005
Offline
i create a script like this:

set oplist = `execute(“opls -d sphere*”)`
if ($oplist) then
echo ok
else
echo Sorry, object not found.
endif

but i got error: invalid if syntax, i checked that this happened probably because the $oplist has an array-like value. I mean , it works if the $oplist contain single numeric value or string etc.
anyone know how to fix it?
the goal with that ‘if’ is to check if the opls command return any value or not(null)

clay~
User Avatar
Member
321 posts
Joined: July 2005
Offline
clay
i create a script like this:

set oplist = `execute(“opls -d sphere*”)`
if ($oplist) then
Yeah, this could expand to something like:

if (geo1 geo2 geo3) then

which is pretty non-sensical. Instead, try:

if (“$oplist” != “”) then


Another approach for these kinds of things is:

if (`argc(execute(“opls -d sphere*”))` > 0) then


This will run if the number of words (ops, in your case) is greater than zero.

– Antoine



echo ok
else
echo Sorry, object not found.
endif

but i got error: invalid if syntax, i checked that this happened probably because the $oplist has an array-like value. I mean , it works if the $oplist contain single numeric value or string etc.
anyone know how to fix it?
the goal with that ‘if’ is to check if the opls command return any value or not(null)

clay~
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
  • Quick Links