Forum Discussion

asmatullah's avatar
asmatullah
Contributor
10 years ago

How to implement Enum in Scripting

Hi ,



I want to use enum in my script . I am using Java script for spriting .

Can any one tell me how to implement this .



Thanks ,

Asmat
  • Hi Asmat



    Does this help:





    function myTest()

    {

      
    var TState = ["InTest", "Done", "Deferred", "Cancelled"];

      
    var TStateEnum = new Enumerator(TState);

      
    var currTState;



      
    while (! TStateEnum.atEnd())

      
    {

         
    currTState = TStateEnum.item();

          Log.message(currTState);

         
    TStateEnum.moveNext();

      
    }

    }







    Regards

    Stephen.
  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Asmat



    Does this help:





    function myTest()

    {

      
    var TState = ["InTest", "Done", "Deferred", "Cancelled"];

      
    var TStateEnum = new Enumerator(TState);

      
    var currTState;



      
    while (! TStateEnum.atEnd())

      
    {

         
    currTState = TStateEnum.item();

          Log.message(currTState);

         
    TStateEnum.moveNext();

      
    }

    }







    Regards

    Stephen.
  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Khan



    You've not given us much to go on, but a common example is one where you wish to work through a number of installed browsers.  I have included a code snippet below:





    var browsersEnum = new Enumerator(Browsers);

    var browser;   //a reference to the current browser



    while (! browsersEnum.atEnd())

    {

       browser = browsersEnum.item();

       browser.run("<your URL here>");

       // perform some tasks in browser

       browser.close();

       browsersEnum.moveNext();

    }





    You may also want to read up on the help file.  From the index, search for the 'Enumerator Object'.  Hope this helps.



    Regards

    Stephen.

  • Hi Stephen,



    Considering your example ,In place of (Browsers) if I want to declare a set of Strings then how to declare it .

    Lets say if want to have a enum object like TState = {InTest:0,Done:1;Deffered:2,Cancelled:3} . How to implement this in scripting any more examples .



    Regards ,

    Asmat