Forum Discussion

jab4743's avatar
jab4743
Contributor
6 years ago

How do I dynamically call an Aliases item?

How do I dynamically call an Aliases item? 

 

For example, I have Aliases.Window1 and Aliases.Window2.  I want to create a Function where I can call either Window1 or Window2.

 

Function call_aliases(AliasesName)

Dim tempaliases

 

tempaliases = Aliases.AliasesName

 

 

End function

 

How do I declare the Aliases item and not have the function see Aliases.AliasesName as a string?

7 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    How do I declare the Aliases item and not have the function see Aliases.AliasesName as a string?

    One more possible option is to consider Eval() function.

    E.g. (pseudo-code):

     

    Function test1

      Set obj = call_aliases("Window1")

    End Function

     

     

    Function call_aliases(AliasesName)

     

      Set call_aliases = Eval("Aliases." & AliasesName)

    End function

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Use WaitAliasChild

     

    tempaliases = Aliases.WaitAliasChild(AliasesName)

    • jab4743's avatar
      jab4743
      Contributor

      That doesn't work.  I want something like Regions.Item.   I can hard code the Aliases.Window1 in the called function but that can be painful if I have to hard code every alias.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Define "doesn't work".  What are you passing in in Aliases Name... are you passing in just Window1?  Or are you passing in Aliases.Window1?

         

        There is nothing like Regions.Item.  So, the solution needs to be different.

        Try adding a timeout parameter...

         

        tempaliases = Aliases.WaitAliasChild(AliasesName, 30000)