Forum Discussion

Marsha_R's avatar
Marsha_R
Champion Level 3
10 years ago

Sorting persistent variables

If I look at the persistent variables in the project tab, they are sorted in alphabetical order.  However, when I open the list to use them inside a keyword test, the list is presented in the order that they were originally added.   Is there a way to get them sorted for use in the keyword tests?

4 Replies

  • Hi Marsha,



    You see it sorted in Project Variables is because the Name column is sorted by default. You could write a routine to achieve this. 



    Try this:




    Set arr = CreateObject("System.Collections.ArrayList")


    log.AppendFolder "From Variables"


    for i=0 to project.Variables.VariableCount-1


      log.Message project.Variables.GetVariableName(i)


      arr.Add project.Variables.GetVariableName(i)


    next


    log.PopLogFolder


    arr.Sort()


     


    arrList = arr.ToArray()


    log.AppendFolder "Sorted Array"


    for i=0 to UBound(arrList)


      log.Message arrList(i)


    next


    log.PopLogFolder



    You could refer to arrList in your keyword test for sorted variable list.

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Marsha,

     


    In addition to Amar's reply, I've submitted a suggestion to implement this feature in TestComplete based on your request.


     

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    I'm not sure how Amar's solution would apply to what I need.



    The attached screenshot shows where I think the list should be sorted.  We have a large project and many persistent variables.  Some of us that started at the beginning of the project have an idea where to look for a certain variable in the list, but a new tester just has to search through the list every time, which seems like a waste when TC should be doing it.