Author Topic: Is there a VA command similar to the {CASE} statement in other languages  (Read 2620 times)

Mode1961

  • Newbie
  • *
  • Posts: 14
in DCS World some a/c have a keypad for entering data.

I would love to be able to press individual number keys via VA

e.g.

I say "KeyPad 2312"

I would like the program to select each key on the keypad (in the game) for each number

First a 2, then 3, then 1, then 2

I have a way to 'extract' each individual number using the MOD qualifier but is there a quick way to set up an IF statement similar to the {CASE} statement in other languages.

So it would be something like this (pseudo code)

Checkvalue of number

Case: 1 - execute command if it is a one
Case: 2 - execute command if it is a two

etc.

Any ideas

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2826
Hi, there.

Currently, there is no switch/case statement.  You'll have to suffer through the if/elseif/else routine for now :(

Maybe later, though! 


Something else to consider is an inline function if you've got a lot of items in your switch/case statement:

Code: [Select]


public class VAInline
{
public void main()
{
switch(VA.GetInt("myVar"))
{
case 1:
    VA.ExecuteCommand("some command 1");
    break;
case 2:
    VA.ExecuteCommand("some command 2");
    break;
case 3:
    VA.ExecuteCommand("some command 3");
    break;
case 4:
    VA.ExecuteCommand("some command 4");
    break;
case 5:
    VA.ExecuteCommand("some command 5");
    break;
}
}
}
« Last Edit: June 02, 2018, 10:23:22 PM by Gary »

Mode1961

  • Newbie
  • *
  • Posts: 14
That looks to be exactly what I need, thanks, Going to check it out.