Forum Discussion

smarshall's avatar
smarshall
Occasional Contributor
11 years ago

Parameterizing Object Properties

I know this is possible as I have done it years ago but do not remember the syntax in order to accomplish this.



I have an object and want to compare the existing property with the value.  The property; however, is variable.  How can I call the non-hard coded property variable for comparison?  The CheckProperty will accept the property variable; however, I do not desire to log an error if the checkProperty returns false, nor do I desire to wait for the checkProperty to return true.



i.e.  Hard coded property


If pobjItem.contentText <> pObjValue Then

    
Call bObjectClick(pobjItem, pFindBy, pObjType, pObjValue, pTagName)



     call bFindNativeWebObjectAndClick(pFindBy, pObjType, pObjValue, pTagName, "", "")



End if



i.e. desired function with parameterize call to object property.



pobjType = contentText (This Is passed by another function)



If pobjItem.pobjType <> pObjValue Then

    Call bObjectClick

    Call bFindNativeWebObjectandClick

End if


 



  • VBScript Example of getting object property (With variable (myPropName) property name):

    Sub Main

    Set wShell = CreateObject("wScript.Shell")


    wShell.Run "notepad"


    Set myObj = Sys.Process("Notepad")


    Dim myPropName


    myPropName = "FullName"


    msgbox aqObject.GetPropertyValue(myObj,myPropName),vbSystemModal

    End Sub

    'This is much easier in JScript :)

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor

    VBScript Example of getting object property (With variable (myPropName) property name):

    Sub Main

    Set wShell = CreateObject("wScript.Shell")


    wShell.Run "notepad"


    Set myObj = Sys.Process("Notepad")


    Dim myPropName


    myPropName = "FullName"


    msgbox aqObject.GetPropertyValue(myObj,myPropName),vbSystemModal

    End Sub

    'This is much easier in JScript :)

  • karkadil's avatar
    karkadil
    Valued Contributor
    " I do not desire to log an error if the checkProperty returns false"



    You can simply use CompareProperty instead of CheckProperty. It allows posting general message instead of error.
  • smarshall's avatar
    smarshall
    Occasional Contributor
    CompareProperty requires a string for comparison.  As I desired to find the string using the variable, this would not work.  The getPropertyValue is the function that was needed.