Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
test if accessible object = "object not found"

I'd like to make an if-then test to detect if = "object not found" so I can pop up a message

not tested but handling err would do it IIRC
Just an idea though...
Something like (quick and dirty)

Acc c.find(......)
OnScreenDisplay "Not found"; msg "Object not found"; end

search err handling in help file maybe?

Thanks. I got this to work

Copy      Help
    mes "oh no!"

Copy      Help
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
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?
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.

Forum Jump:

Users browsing this thread: 1 Guest(s)