Jump to content
Sign in to follow this  
Euth

Noobie Question

Recommended Posts

Euth

Hello all,

I am in the beginning stages of writing a complex script to handle all the tedious clicking at work. I'm a support specialist and our call system requires 54 clicks to process a call. Most of the things we do to process a call is the same, thus creating a macro should be pretty easy. The problem I am having is trying to figure out how to exit or end the parent function if a nested function detects an error popup.

I have looked at exitloop, which looks great because you can give it a level, but I don't think that's going to work in a function (since it's not actually a loop). Exit looks good but doesn't have a level option. I believe I could create the error detect function to set a global variable and then have the parent function check for that variable after the nested function ends and then exit if it's set, but I would like to have a single function to check for this error popup and tell the parent function to exit. I will have to check for this error popup between each of the clicks (54 clicks just for the call process function, let alone the other functions I will be writing) so getting it down to a single function would be best.

I am an experienced PHP developer so picking up this AutoIt language was fairly easy for me to get started. However, I've never had to do anything like this in PHP so I don't really know if what I am trying to do it possible.

Can anyone point me in the right direction?

Share this post


Link to post
Share on other sites
muncherw

What do you mean by "ending the parent function"? Are you wanting to end the program entirely if you get the error popup?


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites
Euth

Something like this

func myfunc ()
_click($var1,$var2)
_checkforerror()
_click($var3,$var4)
_checkforerror()

endfunc

If the for check for error produces an error, the whole function exits.

This there is no _click @ $var3,$var4.

Hopefully that helps explain things a bit.

I don't want to exit the script entirely. I want to exit myfunc().

I'd post my code, but right now I am just writing the error checking functions, thus I don't have a pertinent example.

Edited by Euth

Share this post


Link to post
Share on other sites
muncherw

Can you not put the whole thing in a while loop that runs as long as _checkforerror() doesn't have an error?


Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]

Share this post


Link to post
Share on other sites
MrMitchell

Say Function1() calls Function2() somewhere within.

I would just state in Function1:

If NOT Function2() Then Exit

Then have Function2 return 1 on success or 0 on failure. That way if it fails due to some error and returns 0, then Function1 will Exit instead of continue. That's the approach I've always taken, so now I'm curious to read about all these different solutions...

Share this post


Link to post
Share on other sites
Euth

Can you not put the whole thing in a while loop that runs as long as _checkforerror() doesn't have an error?

I never thought of that.

That may be the answer I need.

I'll proceed. If I have problems, I'll be back.

Thanks a bunch for the idea. ^_^

Share this post


Link to post
Share on other sites
Euth

Say Function1() calls Function2() somewhere within.

I would just state in Function1:

If NOT Function2() Then Exit

Then have Function2 return 1 on success or 0 on failure. That way if it fails due to some error and returns 0, then Function1 will Exit instead of continue. That's the approach I've always taken, so now I'm curious to read about all these different solutions...

Both great suggestions!!!

Thank you both for the great insight!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×