Jump to content
PlatinumFishy

Need help with simple string manipulation

Recommended Posts

5ac7d38550a76_stringhelp.JPG.b79b803e907b38678d2376f6af95b95b.JPG

Trying to access a dynamically generated parameter from my control node and eventually put it into an array. I just do not  understand why using the path variable is any different from just reading the string directly.

 

here it is in text form btw

int maxi = 2;

for(int i = 1; i < maxi; i++){
string path = sprintf("../control/parm%g", i);
s@path = path;
//works^

float param = `chs("../control/parm1")`;
f@param = param;
//works^

float value = `chs(path)`;
f@value = value;
//doesnt work^
}

 

 

Edit : Ive added a simple project file

vex calling.hiplc

 

Edit2: Okay I figured It out, I need to get rid of the back quotes encasing the chf() in order for it to work properly. This probably has to do with me copying the parameter and pasting relative reference in order to get the syntax.  

Edited by PlatinumFishy

Share this post


Link to post
Share on other sites

what does the error says ? Is it a problem a problem of casting of types ?

maybe try chf() instead of chs()... depending on the type returned by the channel

Share this post


Link to post
Share on other sites

the problem is that you cant have a string in a float attribute. floats can only be numbers.

Share this post


Link to post
Share on other sites
15 minutes ago, StepbyStepVFX said:

what does the error says ? Is it a problem a problem of casting of types ?

I'm sorry I should've included that, it says: "Syntax error, unexpected ';'.

Share this post


Link to post
Share on other sites
5 minutes ago, davpe said:

the problem is that you cant have a string in a float attribute. floats can only be numbers.

What do you mean? I am using the path variable to store the reference nor the actual value. When getting the value for the param variable I also used a string within the chs() and it worked.

string help 2.JPG

Share this post


Link to post
Share on other sites

your value variable is cast as a float, but you assign it the value of a string by using `chs()`

Edited by Jesper Rahlff

Share this post


Link to post
Share on other sites
16 minutes ago, Jesper Rahlff said:

your value variable is cast as a float, but you assign it the value of a string by using `chs()`

Again, am I not doing the same thing for the param variable?

this works: float param = `chs("../control/parm1")`;

That is also using the chs() and it reads into a float.

 

 

Edit: Okay I figured It out, I need to get rid of the back quotes encasing the chf() in order for it to work properly. This probably has to do with me copying the parameter and pasting relative reference in order to get the syntax.  

Edited by PlatinumFishy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×