So i was wondering what the simplest way to handle 50 some commands would be.
Say a user enters a command in a textfield and the code needs to handle each command separately. Is there something shorter than a if/else or case/break?
Thanks.
So i was wondering what the simplest way to handle 50 some commands would be.
Say a user enters a command in a textfield and the code needs to handle each command separately. Is there something shorter than a if/else or case/break?
Thanks.
Ahhh a minimum information problem
To get a useful answer you might want to include more information such as
Thanks for the reply.
Working on this terminal software(Java mode) and am adding commands for user customization .e.g. (Font type, Color scheme, Language). Mainly to keep UI from being cluttered. The commands would be pretty simple for instance.
if (input == "f-unifont") {
systemFont = "unifont";
}
So an if statement might not be the worst.
I see now that switch statements won’t work with strings(input from software is string type) so that one is out.
The reference does not show String as an expression but it will work.
switch / Reference / Processing.org
Example with a String:
String s = "B1";
//s = "A0";
switch(s) {
case "A0":
println("Alpha"); // Does not execute
break;
case "B1":
println("Bravo"); // Does not execute
break;
default: // Default executes if the case names
println("None"); // don't match the switch parameter
break;
}
The correct way to compare Strings is discussed here:
:)