Forum Discussion

Manfred_F's avatar
Manfred_F
Regular Contributor
10 years ago

distinguish Alias from Control

How can I determine, whether an object variable holds an alias (that does not exist) or a control(that also doesn't exist anymore)?

An alias generates an errot "The OBject does not exist", if You access other properties than .Exists...

 

Regards,

Manfred

  • Manfred_F's avatar
    Manfred_F
    10 years ago

    Hi Tanya,

    thank You for Your proposal.

    I finally found the following approach that works:

    (in pseudo-code)

     

    // set auto-timeout to little value so we don't have to wait that long

    // block TC error-logging, so we don't stop when we generate an error

    // disable vbs error handling, too (accessing a non-existing control's property will raise an error)

     

    // for a not yet existing alias, You get an object when accessing a property, for a no more existing control, You get an error

    Result = isObject(myObject.Top)

     

    // restore vbs error handling

    // unblock TC error logging

    // reset auto-timeout to former value

     

    Regards,

     

    Manfred

     

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Manfred,

    You can do something like this:

    if (MapObj.WaitAliasChild(“MapObj2”, 3000).Exists )

    {

    //Do something

    }

    • Manfred_F's avatar
      Manfred_F
      Regular Contributor

      Hi Tanya,

      thank You for Your proposal.

      I finally found the following approach that works:

      (in pseudo-code)

       

      // set auto-timeout to little value so we don't have to wait that long

      // block TC error-logging, so we don't stop when we generate an error

      // disable vbs error handling, too (accessing a non-existing control's property will raise an error)

       

      // for a not yet existing alias, You get an object when accessing a property, for a no more existing control, You get an error

      Result = isObject(myObject.Top)

       

      // restore vbs error handling

      // unblock TC error logging

      // reset auto-timeout to former value

       

      Regards,

       

      Manfred