Forum Discussion

ajb's avatar
ajb
Occasional Contributor
8 years ago
Solved

Would like to generalize a table comparison in VBScript

Working with VBScrip tScripting. I am trying to create a general purpose script to run my browses and compare the output. 

Starting with:

 

Call Tables.SDTCode1.Check

 

I would like to use a parameter for "SDTCode1" so that this script can be generalized and used for all browses with just a change to the parameter containing the Table name. Tried a few different things but I must be missing something fairly easy. Any suggestions?

  • You could use Execute to run code as string:

    strTableName = "SDTCode1"
    Execute("Tables." & strTableName & ".Check")

    Or something like this:

    strTableName = "SDTCode1"
    Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
    Call tblCheckpoint.Check

     

    Or if you want to compare the same table to multiple objects, use the CompareWithObject method instead of Check:

    Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object1)
    Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object2)

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    You could use Execute to run code as string:

    strTableName = "SDTCode1"
    Execute("Tables." & strTableName & ".Check")

    Or something like this:

    strTableName = "SDTCode1"
    Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
    Call tblCheckpoint.Check

     

    Or if you want to compare the same table to multiple objects, use the CompareWithObject method instead of Check:

    Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object1)
    Call Tables.SDTCode1.CompareWithObject(Aliases.MyApp.Object2)
    • ajb's avatar
      ajb
      Occasional Contributor

      Thank all of you for your speedy replies. This seemed to work for me in VBScript:

       

      strTableName = CompTable
      Set tblCheckpoint = aqObject.GetPropertyValue(Tables, strTableName)
      Call tblCheckpoint.Check

       

      Where CompTable is the parameter containing the name of the Table.

       

      Thanks again. Now I can have one script for all our browses changing just the criteria passed in and the appropriate table to compare the output.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Have you tried using aqObject.CallMethod? What you can do is use a call to FindChild or Find on your "Tables" to find the specific child object, return that object as a varible, and then call the "Check" method.  something like ( am NOT well versed in VBScript so consider this pseudocode):

     

    Set MyObject = Tables.FindChild('SDTCode1');
    aqObject.CallMethod(MyObject, 'Check')