Jump to content
Sign in to follow this  
Trancor

Eval in VEX?

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

Share this post


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

Share this post


Link to post
Share on other sites
// preview of attributes
string A = "90";
string B = sprintf("%d",i@ptnum);

// atof() converts string to float, sprintf print sum of i@ptnum and A to string @C
s@C = sprintf("%d",i@ptnum+atof(A));

Cheers,

Petr

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

can you use snippets?

 

check out some of the pop nodes like wind.  they have user entered vex code as part of their functionality.

Share this post


Link to post
Share on other sites

Not in this case, I sort of gave up and just added a VEXpression parameter, I guess similar to snippets, but to set point attributes for the code I'm writing to read from.
Annoying, but works.

Share this post


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

Share this post


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

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
Sign in to follow this  

×