samedi 24 novembre 2018

Autogenerate cases for a switch. Or another suggestion

Is there any way to autogenerate cases if necessary (with certain logic described by example) for a switch? Or maybe you have another suggestion (i am just a newbie)

    int num = 0; // Global variable
    .
    .
    . 
    switch (num)
    {
    case 0:
    {
        //some code
        num++;
        break;
    }
    case 1:
    {
        if (CHECK(1)) // CHECK is macros for comparing 
        {
            //some code
            num++;
        }
        break;
    }
    case 2:
    {
        if (CHECK(1) && CHECK(2))
        {
            //some code
            num++;
        }
        break;
    }
    case 3:
    {
        if (CHECK(1) && CHECK(2) && CHECK(3))
        {
            //some code
            num++;
        }
        break;
    }
    case 4 ...

... and so on

Aucun commentaire:

Enregistrer un commentaire