Jump to content

Eval in VEX?


Trancor

Recommended Posts

Hey guys, I searched around for this and can't seem to find a solution, maybe you guys know.

To simplify what I'm doing (its quite more complicated than this, but, ya know), lets just say I have this set up-
string A = "91+";
string B = @ptnum;
string C = A+B;
C == "91+1",  "91+2",  "91+3" . . .

Is there an eval I can do in VEX to get a result like this per point?
91
92
93
94
95

I've tried doing things like -
float( C ) == errors out
or
atof( C )  == "91"

But it doesn't seem to work for me.

Is there any sort of - eval( C )
Or another way to evaluate the string variables as an expression/math?
I'm considering just adding new parameters to evalutate the math through python and to read the parameters into the vex, but is there an easier way to do this?

Edited by Trancor
Link to comment
Share on other sites

I'm completely guessing, but could this work

string A = "91";
string B = @ptnum;
string C = ftoa(atof(A)+atof(;

having the operator "+" in the string is a bit of a problem I think.

Edited by 3iart
Link to comment
Share on other sites

Hey guys, thanks for the replies.
The problem is, I can't remove the +
Its goin to be "90+"  or "sin($F)+"  or some variant with the operators built into the string being passed.

Thats why I was hoping for an eval command to process the string like a math problem.

eval("91+5*"+@ptnum);

Type of thing.
atof( )  only grabs the first number in the string it finds, as it appears.
 

Edited by Trancor
Link to comment
Share on other sites

User input basically.
It'll find a string like "40*5+@ptnum" and I'm just looking to get the value of that math in VEX.

To mimic eval( )  from any number of other scripting and programming langues.

Edited by Trancor
Link to comment
Share on other sites

you can as well insert content of user input parameter into your vex code

 

some vex code `chs("../userinputparm")` more vex code;

 

it will get expanded before compilation, then it will evaluate as a vex code

it won't work however for animated parms as it get's expanded only on the first frame

Link to comment
Share on other sites

Thanks everyone.
Captain, I think that might be the solution here.  Not a fan though, hahah.
Since its all VEX, parsing out the string in python and applying any particle numbers seems futile to me.
 

I got around it with just opening up a VEXpression input on my otl, changes workflow a little, but at least it works.

 

I just figured, every languages I've ever used had an eval command, was sort of hoping VEX had

Edited by Trancor
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...