Jump to content

VEX : array with operators (*,+,/,-) inside a loop


Recommended Posts

Hi There,

I am trying to procedurally grab an operator from an array ex. array("*","+","/","-") and use it inside a loop to do a simple calculation.

Here is an example:

string operators[] = array("*","+");
f@tmp = 1;

for(int i=0;i<chi("iter");i++){

    f@tmp `operators`= 2; //how do I convert the operators result to something meaningful for vex?


When I use an "i" as an index it doesnt error but it ignores whatever is inside the ``. If I add 0 as an index I am getting an error.

I have managed to make it work with an ordered menu by using `chs("orderedMenu")` and that works fine, although is not as flexible. In my case I don't want to use this approach cause I am going to end up with various different ordered menus. I would prefer if I could store the values of the ordered menus in an array and run it in a loop. 

Probably I don't understand the difference of the result between the ordered menu and the array and I am not even sure whether what I am trying to do is valid. 

If anyone could help with this would be great! I have attached a simple example in case anyone would like to have a look.


Thanks in advance guys,




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.

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...