Forum Discussion

VasanthVijay's avatar
VasanthVijay
Contributor
11 years ago

Reg:Array relate querry

sample example

var array = new array('0','1');

for(i = 0;i < array.length;i++)

{

    switch()

    {

        case 0:

             log.message('hi');

            break;

       case 1:

            log.message("hello");

           break;

        default :

         break;

     }

}





i want out put of

hi and hello but only showing hi

how to fix this one.



thanks in advances

vasanth.v
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Hey, Ryan...



    If you wrap your code in tags where you do square-bracket code square bracket, the forums do VERY nicely with code.



    function TestCodeTags()

    {

        var TestVariable;

        TestVariable = "This is a test using code tags"

        Log.Message(TestVariable)

    }
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    var arr = new Array('0','1');


    for(i = 0;i < arr.length;i++){


     switch(arr\[i\]){


      case '0':


       Log.message('hi');


      break;


      case '1':


       Log.message("hello");


      break;


      default :


       Log.message("default");


      break;


      }


     }



    //this forum butchers code

  • Thanks moran

    suppose i have



    var arr = new Array('0','1');


    for(i = 0;i < arr.length;i++){


     switch(arr){


      case  odt.classe.hi:


       Log.message('hi');


      break;


      case odt.classe.hello:


       Log.message("hello");


      break;


      default :


       Log.message("default");


      break;


      }


     }



    how can we use in odt classes


     



     


     

  • chrisb's avatar
    chrisb
    Regular Contributor


    var myVarName = new Array(0, 1);



    for (i = 0; i < myVarName.length; i++) {



        switch (myVarName[ i ]{

        case 0:

            Log.Message("hi");

            break;

        case 1:

            Log.Message("Hello");

            break;

        default:

            break;

        }

    }



     



  • var arr = new Array('0','1');


    for(i = 0;i < arr.length;i++){


     switch(arr){


      case  odt.classe.hi:


       Log.message('hi');


      break;


      case odt.classe.hello:


       Log.message("hello");


      break;


      default :


       Log.message("default");


      break;


      }

     }



    but we need to give the Array to use this rite

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    I don't believe so...




    if (ODT.Classes.hi){


     Log.message('hi');


     }


    if (ODT.Classes.hello){


     Log.message('hello');


     }

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    :)

    Thanks for the tip with the code tag Robert.

    I don't usually participate in forums so I'm still a bit of a noob in that regard.