SWITCH / CASE - MX

Switch (var) {

case 1 : ...

case 2 : ...

...}

Treating multiple cases without using if

int num=Str.ToInt(_str26);

switch (num) {
    case 1: return Str.RemoveAfter(_str1," ");
    case 2: return Str.RemoveAfter(_str2," ");
    case 3: return Str.RemoveAfter(_str3," ");
    case 4: return Str.RemoveAfter(_str4," ");
}

return "";

// Or with discretes:

String equipe = _str1;
switch (equipe) {
    case "ASM Clermont" : return _str2;
    case "Brive" : return _str3;
    case "Castres Olympique" : return _str4;
    case "Grenoble" : return _str5;
    case "La Rochelle" : return _str6;
    case "Montpellier Hérault" : return _str7;
    case "Oyonnax" : return _str8;
    case "Racing Metro 92" : return _str9;
    case "Section Paloise" : return _str10;
    case "Stade Francais" : return _str11;
    case "Toulon" : return _str12;
    case "Toulouse" : return _str13;
    case "Union Bordeaux" : return _str14;
    case "Agen" : return _str15;
}

return "";

//If you don't want to return something, you can add "break;" at the end of each case:

String mois =_str1;
String month = "";
switch (mois) {
    case "Jan" : month="01";break;
    case "Feb" : month="02";break;
    case "Mar" : month="03";break;
}

Was this article helpful?

Powered by Zendesk