Nested Backticks in String Expression

   1508   4   0
User Avatar
Member
18 posts
Joined: Dec. 2020
Offline
I seem to remember hearing about this somewhere, but can only find this thread from 2011 that doesn't seem to work in my situation:
https://www.sidefx.com/forum/topic/21476/ [www.sidefx.com]

string @mypath = "`ch("../../../`opname("../../")`")`";

This is part of an HDA in which I need the global path to an object that's been drag & dropped into a link field in the HDA parent object. Is there an alternate symbol to use for the nested backtick?

Thanks,
Luke
User Avatar
Member
7803 posts
Joined: Sept. 2011
Offline
LukeLetellier
I seem to remember hearing about this somewhere, but can only find this thread from 2011 that doesn't seem to work in my situation:
https://www.sidefx.com/forum/topic/21476/ [www.sidefx.com]

string @mypath = "`ch("../../../`opname("../../")`")`";

This is part of an HDA in which I need the global path to an object that's been drag & dropped into a link field in the HDA parent object. Is there an alternate symbol to use for the nested backtick?

Thanks,
Luke

no, no nested backticks. However, you can do string concatenation. I'm not sure why you want to use an expression in the VEX code rather than a chs() function.

I would put:

string @mypath; // You don't set a default value for strings as it will be ignored
@mypath = chs("path");

and in the parm 'path' on the wrangle add a keyframe and set the expression to:

chs("../../../"+opname("../.."))
Edited by jsmack - June 13, 2022 17:10:26
User Avatar
Member
18 posts
Joined: Dec. 2020
Offline
Doh! Thank you. Didn't have my brain screwed on correctly; should have grasped the string concatenation from the previous thread.

A question though; when I try to write or paste your code into the channel slot, H automatically adds adds a number of backslashes as soon as I click away which causes it to error out, so that:

What starts out as this:
chs("../../../"+opname("../.."))

Ends up looking like this:
chs(\"../../../\"+opname(\"../..\"))

And every time I try to get rid of them, H just adds them back in. Thoughts?

I'll probably just try piecing my code together in two separate VEX lines and merging them together without channels, but I'm curious about the backslashes in case I run into them again in the future.

Thanks!
Luke
Edited by LukeLetellier - June 14, 2022 12:03:49
User Avatar
Member
8595 posts
Joined: July 2007
Online
LukeLetellier
And every time I try to get rid of them, H just adds them back in. Thoughts?
you have probably pasted it to your parameter with keyframe when it was evaluating as string as opposed to when it's showing raw expression
you your choices are, click on the label to toggle it to expression and then paste it in

or what I prefer for string parameters:
delete all keyframes from the parameter so that its black again
and paste something like this
`chs("../../../"+opname("../.."))`
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
18 posts
Joined: Dec. 2020
Offline
Good to know; thank you!
  • Quick Links