dbRackFormulaOne icon indicating copy to clipboard operation
dbRackFormulaOne copied to clipboard

Question about syntax for a switch!

Open jaffasplaffa opened this issue 3 years ago • 4 comments
trafficstars

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

jaffasplaffa avatar Oct 19 '22 11:10 jaffasplaffa

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

docb avatar Oct 19 '22 11:10 docb

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

jaffasplaffa avatar Oct 20 '22 09:10 jaffasplaffa

@jaffasplaffa I think you probably want this:

https://www.partow.net/programming/exprtk/readme.html#line_0626

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

ArashPartow avatar Nov 01 '22 14:11 ArashPartow

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!

jaffasplaffa avatar Feb 03 '24 12:02 jaffasplaffa