Jump to content

Need help with simple string manipulation


PlatinumFishy

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
Link to comment
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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...