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

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

Thanks.
#2
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
#3
Thanks. I got this to work

Code:
Copy      Help
err
    mes "oh no!"
    end
#4
Try:



Code:
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
#5
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?
#6
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


Forum Jump:


Users browsing this thread: 1 Guest(s)