Posts: 197
Threads: 60
Joined: Dec 2013
Hi,
I'd like to make an if-then test to detect if = "object not found" so I can pop up a message
Thanks.
Posts: 795
Threads: 136
Joined: Feb 2009
not tested but handling err would do it IIRC
Just an idea though...
Something like (quick and dirty)
Acc c.find(......)
err
OnScreenDisplay "Not found"; msg "Object not found"; end
search err handling in help file maybe?
HTH
Posts: 197
Threads: 60
Joined: Dec 2013
Thanks. I got this to work
Posts: 1,006
Threads: 330
Joined: Mar 2007
Try:
int w=win("WinName" "WinClass")
Acc a.Find(w "PUSHBUTTON" "Log On" "class=*.BUTTON.*[]wfName=buttonLogin" 0x5)
if a.a
,out "exists"
if !a.a
,out "doesn't exist"
make sure you uncheck error if not found (so no flag 0x1000) but don't then trap the err with an ;err at the end of the acc statement or else it will always return true even when not present
Posts: 197
Threads: 60
Joined: Dec 2013
Thanks for the tip, but I tested this macro and it seemed to work fine.
For example,
when the object is found, it was clicked
when the object was not found, it displayed my message
That's exactly what I wanted so am I missing something?
Posts: 1,006
Threads: 330
Joined: Mar 2007
probably Gintaras or other advanced programmers can answer better. Learning from examples on this site and others, I think it's better programming practice to test conditionality using the properties of the class variable than by "erroring out" and then trapping the error. It probably limits you in some way in certain situations but can't exactly explain why.
S