Forum Discussion

albertopasion's avatar
albertopasion
Occasional Contributor
14 years ago

Log.LockEvents(0)

I have set the Log.LockEvents(0);


I have a code that checks if a form is visible on a while loop:


  while PX3000Client.TMessageForm3.visible do 

     PX3000Client.TMessageForm3.OK.ClickButton;


when the form is not visible anymore, I get an error message on the test log.  


==================================================


An error occurred when executing the "visible" method or property of the "TMessageForm3" object.

The object or one of its parent objects was not found in the system.



Tested Object

------------------

Alias: Aliases.PX3000Client.TMessageForm3

Mapping item: NameMapping.Sys.PX3000Client.TMessageForm3



Missing Object

------------------

Alias: Aliases.PX3000Client.TMessageForm3

Mapping item: NameMapping.Sys.PX3000Client.TMessageForm3


Is there a method of preventing this error from being posted on the log?
 


Thanks in advance.


Albert

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Log.LockEvents will only affect log entries of type "Event".  As this is an error, it is not affected by LockEvents.



    That said, you cannot check the property of an object that does not exist. :-)  The object in question, if it does not even exist, will not even resolve to be able to determine if it is visible or not.



    I would suggest that you actually do the following loop instead:



    while PX3000Client.WaitAliasChild('TMessageForm3', 500).Exists do begin

         if PX3000.TMessageForm3.Visible then

             PX3000Client.TMessageForm3.OK.ClickButton;

         end;





    That will first check if the object exists before it checks the visible property.
  • albertopasion's avatar
    albertopasion
    Occasional Contributor
    Thanks again Robert.  I got the idea and thanks for the suggested code too.