Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about syntax for a switch! #2

Open
jaffasplaffa opened this issue Oct 19, 2022 · 4 comments
Open

Question about syntax for a switch! #2

jaffasplaffa opened this issue Oct 19, 2022 · 4 comments

Comments

@jaffasplaffa
Copy link

jaffasplaffa commented Oct 19, 2022

Hey :)

I've made this switch for testing and I can't get it to work. Probably some syntax thing I am not getting right. I am hobby coder so no expert, but I do have a little experience.

Here is an example. This does not work in Formula One:
Screenshot 2022-10-19 at 13 24 42

First I assign a variable. Then I have the switch. Then assign switch result to output.

What am I doing wrong?

Thanks in advance,
Jaffa

@docb
Copy link
Owner

docb commented Oct 19, 2022

hi, it works like this:

var test;

switch {
  case x==0:  test := 0;
  case x==1:  test := 1;
  case x==2:  test := 2;
  default: test := 0;
}

var out := test;

see also:
http://www.partow.net/programming/exprtk/code/readme.txt (6) Control Structures

best regards

@jaffasplaffa
Copy link
Author

Hey :)

Thanks for the quick reply. I was not able to get {} working using a classic switch(I'd like to use more than one statement pr. case, so I ended up using if statements like this:
if(x=0){code};
if(x=1){code};
if(x=2){code};

That works.

Thanks for the reference, that's really nice to know. I could figure some of it out on my own, from looking at the examples, but not all of it.

Do you think it's possible to have a link to that read me file in the same drop down menu as the manual?

It would be lovely to always have that the read me as a quickly accesable tool, like the manual.

Screenshot 2022-10-20 at 11 31 19

@ArashPartow
Copy link
Contributor

@jaffasplaffa I think you probably want this:

https://github.com/ArashPartow/exprtk/blob/master/readme.txt#L613

Example usage:
https://github.com/ArashPartow/exprtk-extras/blob/master/exprtk_fizzbuzz.cpp#L38

@jaffasplaffa
Copy link
Author

Hey guys :)

Sorry for the late reply!

Just want to say thanks for the tips, they were really helpful ;)

I managed to get most of the stuff I've been working on working now, with help from the documents you provided.

This absolutely one of my favourite VCV modules. The amount of module/cable clutter has been greatly reduced in my patches, by using this module.

it's just awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants