String comparison in Hscript

   4989   4   0
User Avatar
Member
55 posts
Joined: March 2015
Offline
So I need to drive a switch sop based on a parameter in another sop, to do so I've written the folliwng code:

{
    if ( ch("../my_parameter/group1") == "none" )
    {
        return 0;
    }
}

And this is the error I get:

Error:       Unable to evaluate expression (Bad data type for function or operation (/obj/geo1/HDA_1/switch1/input)).

How can I compare two strings in Hscript?
Edited by SteN - April 15, 2017 16:22:37
https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
7722 posts
Joined: July 2005
Online
The
ch()
expression returns a float, not a string. For strings, you need
chs()
(note the s after ch).
User Avatar
Member
55 posts
Joined: March 2015
Offline
edward
The
ch()
expression returns a float, not a string. For strings, you need
chs()
(note the s after ch).

Yea I forgot to mention: it doesnt work even with the chs() function.

Here's an example file.
(Im still working in H15.5)
Edited by SteN - April 15, 2017 17:16:21

Attachments:
Hscript_error_example.hipnc (50.4 KB)

https://vimeo.com/user43100796 [vimeo.com]
User Avatar
Member
8555 posts
Joined: July 2007
Offline
you have to use strcmp()

{
    if(strcmp(chs("../random_node/geotype"), "poly")==0)
    {
        return 1;
    }
}

and not sure but the values you are refering here (“none”) or in your file (“primitive”) are not valid for group geotype parm, so it would never switch to one anyway
the valid values are:
'all', ‘bezierc’, ‘bezier’, ‘mesh’, ‘circle’, ‘MetaSQuad’, ‘meta’, ‘nurbc’, ‘nurb’, ‘PackedAgent’, ‘AlembicRef’, ‘PackedDisk’, ‘PackedFragment’, ‘PackedGeometry’, ‘part’, ‘PasteSurf’, ‘poly’, ‘polysoup’, ‘sphere’, ‘tetrahedron’, ‘trifan’, ‘tristrip’, ‘tribez’, ‘tube’, ‘vdb’, ‘volume’
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
55 posts
Joined: March 2015
Offline
tamte
you have to use strcmp()

{
    if(strcmp(chs("../random_node/geotype"), "poly")==0)
    {
        return 1;
    }
}

and not sure but the values you are refering here (“none”) or in your file (“primitive”) are not valid for group geotype parm, so it would never switch to one anyway
the valid values are:
'all', ‘bezierc’, ‘bezier’, ‘mesh’, ‘circle’, ‘MetaSQuad’, ‘meta’, ‘nurbc’, ‘nurb’, ‘PackedAgent’, ‘AlembicRef’, ‘PackedDisk’, ‘PackedFragment’, ‘PackedGeometry’, ‘part’, ‘PasteSurf’, ‘poly’, ‘polysoup’, ‘sphere’, ‘tetrahedron’, ‘trifan’, ‘tristrip’, ‘tribez’, ‘tube’, ‘vdb’, ‘volume’
Thanks!
I didnt know the strcmp() function, now it works.

That chs(“../random_node/geotype”) I just used it as an example, the real channel is referring to an ordered menu wich contains a “none” option in it
https://vimeo.com/user43100796 [vimeo.com]
  • Quick Links