Forum Discussion

ZooZoo's avatar
ZooZoo
Occasional Contributor
15 years ago

Array Declaration Issue

Script


function ReadWholeFile(strPath)


{


  var FileCon = new Array();  


  FileCon = new Array (6);


  var FileName = aqFile["OpenTextFile"](strPath, aqFile["faRead"], aqFile["ctANSI"]);  


 


  // Obtains the total number of lines in the file


  var LineCount = FileName["LinesCount"];


  FileName["SetPosition"](1, 0);


  for (var i = 0; i < LineCount; i++)


  {


    // Obtains the current line          


      while (! FileName["IsEndOfLine"]() )  


        {


        // Obtains the letter and its number


        var sLet = FileName["ReadString"](1);


        var LineCount = FileName["Column"];


        // Specifies the string


        var strDelimiter = "|"; 


        var FileValue = FileName["ReadToSymbol"](strDelimiter);


        Log["Message"](FileValue);


/* here I want to get the values in a array. After reading the file I want to compare the values to select a appropriate function using switch case.*/


        }          


  }


}


 


 


.txt file


ScreenName,FuncOrStepCall,WindowName,ObjectName,DataSet1,DataSet2


User Signon,TxtSetTxtboxValue,Login,obj1,1234,


Search button,ObjClickObject,Login,obj2,


Form Load,AppWaitScreen,Login,,2000,


Role,DdlSetDropdownListValue,Login,obj3,Teller,


 


 


I have searched  all the test complete help, but am facing issue while declaring array and using the same. If anyone knows help me to declare a array and how to assign the values in  run time. (I want to get the values inside the while loop in a array).

4 Replies

  • Hi,



    Use your array's push method to add values to it on each loop iteration.

    Arrays are described here.
  • ZooZoo's avatar
    ZooZoo
    Occasional Contributor

    Thanks a lot Jared for your timely and appropriate inputs (help).

  • ZooZoo's avatar
    ZooZoo
    Occasional Contributor

    Hi,


    Requirement:- In run time I have to get the select value for an object.


                    For example: I have to get selected value for “Drop down”  box or “List box” or “text box”.


     


    Text box value is available in property “Text”


    Drop down box value is available in property “wText”


    List box value is available in property “wSelectedItems”


     


    var GetTextValue, ObjectType, ex;


    ObjectType = aqObject["GetPropertyValue"](ObjectName, "ObjectType");


          switch (ObjectType)


            {            


            case "Textbox":  //Text Box


              GetTextValue = aqObject["GetPropertyValue"](ObjectName, "Text");


              break;


             


            case "Select":    //Dropdown


              GetTextValue = aqObject["GetPropertyValue"](ObjectName, "wText");


              break;


             


            case "Select":  //List box


              GetTextValue = aqObject["GetPropertyValue"](ObjectName, "wSelectedItems");  


              break;          


            }

     


    Based on the object type the selected value will be differ.      


























    Name



    Object Type



    Value



    Text Box



    Textbox



    Text



    Dropdown



    Select



    wText



    List Box



    Select



    wSelectedItems



     

    I am getting the “Object Type” value in run time.

    ObjectType = aqObject["GetPropertyValue"](ObjectName, "ObjectType");


     

    Both Dropdown and list box contain the same object type as “Select”. But the value is available in different property like “wText” and ”wSelectedItems”.


     

    1.       Please let me know how to differentiate the two objects? (I have searched the different properties but I didn’t get)


    2.       Let me know how to use the  “wText” and ”wSelectedItems” in the above switch case.


     Thanks...