print string var in hscript expression?

   375   4   1
User Avatar
Member
65 posts
Joined: 4月 2020
Offline
this is a stupid question because i can just use python instead..haha....

but it's killing me that i can't do such a simple thing as print this current string value and was curious if anyone knew how to do it? i seem to remember having to use tildes(?backticks?) for getting access to a string but i tried a bunch of attempts at that and all failed.

anyways, if anyone knows how to print this current var value, i'd love to hear it. hah.

Attachments:
string attrib.jpg (145.9 KB)

User Avatar
Member
9121 posts
Joined: 7月 2007
Offline
indigosm
i seem to remember having to use tildes(?backticks?) for getting access to a string but i tried a bunch of attempts at that and all failed.
in string parameters use backticks to evaluate any expression and chs() instead of ch() to reference string parameter instead of numericla one, so in your case:
`chs("../UV_Attrib")`
or RMB/Copy Parameter and RMB/Paste Relative References will do it for you
then you can MMB on the parameter label to switch between showing the expression and the resolved value

it's not to print to the console, but nevertheless it would reference the value in the parameter so you will see it there
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
65 posts
Joined: 4月 2020
Offline
correct, but how do i print it?

for example, this is the hscript expression now. it prints 'test 0'

{
    test = 'chs("../UV_Attrib")';
    print("test",test);
    return 0;
}
    
Edited by indigosm - 2025年2月25日 11:44:39
User Avatar
Member
9121 posts
Joined: 7月 2007
Offline
never used print in Hscript, but from a quick test it looks like the second argument just expect numbers
so you need to use the first argument for string like this:
{
    string test = chs("../UV_Attrib");
    print( test, 0);
    return 0;
}
or if you want to join with other text
{
    string test = chs("../UV_Attrib");
    print( strcat("test: ", test ), 0);
    return 0;
}

NOTE: since it seems like you are putting it in switch/input integer parameter so you don't need backticks at all (and if needed, when mixed with string characters in string parm, they would be around the whole expression)
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
65 posts
Joined: 4月 2020
Offline
edit.

aha! that fixes it! thank you so much!!!
Edited by indigosm - 2025年2月25日 12:12:57
  • Quick Links