Forum Discussion

paarmann-ara's avatar
paarmann-ara
Contributor
5 years ago
Solved

wItemCount and WaitProperty

I have Qustion about WaitProperty!

I want know, may I use a Secound Parameter of WaitProperty like a boolian or how can I?

 

like:

Object.WaitProperty(wItemCount, wItemCount > 0)

  • This is a error:

    The window with the 0x00010800 handle exists but did not respond during the auto-wait timeout (150 ms)

    This error raised because ListView.wItemCount is not ready.


    This could perhaps mean that TCs pointer to the object still exists, but that the item it was pointing to was destroyed, recreated or disposed in some way.  If this is the case, the pointer ha changed and you will have to refresh your object and fetch again.  TC will never find the property even though it thinks it can see it, since that is an old handle

  • tristaanogre's avatar
    tristaanogre
    5 years ago

    What RUDOLF_BOTHMA  sounds like the best case.  This is especially the case if you have assigned an object to a variable at one point in the project and then navigated away or refreshed the screen or something. Everytime you close a window and re-open, you destroy and create object handles.  So, if you're persisting an object via variable, you need to refresh it everytime the application recreates the object.  Using WaitChild or WaitAliasChild liberally throughout your code is key to this.  I try to NEVER store on-screen objects in global variables and keep them scoped to the local function and/or procedure.  

  • RUDOLF_BOTHMA's avatar
    RUDOLF_BOTHMA
    5 years ago

    tristaanogre wrote:

    I try to NEVER store on-screen objects in global variables 


    I recall doing it in the really early days of my TC development.  In the end I always had to refresh & refetch the object everytime, so there was no gain in doing it this way - even a bit of a perfromance loss.  Wait methods in local scope or at least within the local functions where the most reliable and efficient

14 Replies

  • As far as I know, there is no way to do this.  You should however be able to just put in a basic for loop and test the property directly:

     

    var itemsFound = fasle;
    for(var I=0;i<100;i++){
    if(Object.wItemsCount >0)
    itemsFound  = true;
    break;
    Delay(1000);
    Object.Refresh(); //Might be required, but not guaranteed } if(!itemsFound){ Log.Error("No items found in allotted time"); }
    • paarmann-ara's avatar
      paarmann-ara
      Contributor

      Many thanks for your reply.

      I want to use this method to solve a error (window handel exsist but window not). that's not help me :-(

      • RUDOLF_BOTHMA's avatar
        RUDOLF_BOTHMA
        Community Hero

        In that case, you could use the .Exists rather than trying to use a property of the object which may or may not exist

        e.g.

         

        var objtectExists=false;
        var counter = 0;
        
        while(counter<100 && !objectExists)
        {
        counter++;
        if(Object.Exists)
        {
        objectExists = true;
        break;
        }else
        {
        Delay(100);
        ObjectParent.Refresh(); ObjectParent.FindChild("objectname"); //Or similar find method
        // } }