Jump to content

Recommended Posts

Posted

I'm no expert, but are you sure you really need to do that? Why can't you simply have the function return an error code, then do a simple If @error = whatever, _function()... ya know? Of encase the proceeding code in an if/else statement.

Such as,

If @error = whatever

do something

else no error

rest of code here...

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Posted

Ummm. followup question...

Say I have this...

AdlibEnable("Check4Error")

Command1

Command2

Command3

Command4

Command5

Command6

Command7

Command8

exit

and an "error" is encountered during the execution of Command5

after handling the error, do I return to:

Before command 1

Before Command 5

After Command 5

AutoIt is not multi-threaded. So if you want to interrupt a function without returning to it, like start Command5 over if an error occured, then Command5 needs to actually spin off a separate process by way of Run(), ShellExecute(), etc. Then you could monitor for errors and kill/respawn the other process as required. This is not as hard as it sounds. The script can call up another instance of itself, with a command line parameter that causes it to do "Command5". The issue there is getting enough global variables etc. passed for Command5 to operate on, or arranging inter-process comms between the parent and child instances of the script.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

AutoIt is not multi-threaded. So if you want to interrupt a function without returning to it, like start Command5 over if an error occured, then Command5 needs to actually spin off a separate process by way of Run(), ShellExecute(), etc. Then you could monitor for errors and kill/respawn the other process as required. This is not as hard as it sounds. The script can call up another instance of itself, with a command line parameter that causes it to do "Command5". The issue there is getting enough global variables etc. passed for Command5 to operate on, or arranging inter-process comms between the parent and child instances of the script.

:)

Well, the way I think I will handle the issue is:

; Begin adding people
 $TypeOfRow = findtypeofrow()
 $AbortRow = "False"
 Select
  Case $TypeOfRow = 1; Primary Only
   ConsoleWrite("Type of row: 1 - Primary only" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   
   ; Move to Get a Quote button
   AdlibEnable("myadlib")
   If $AbortRow = "False"  Then ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   If $AbortRow = "False"  Then ConsoleWrite("Move to Choose Plans page." & @CRLF)
   Sleep(750)
   
  Case $TypeOfRow = 2; Primary and Spouse
   ConsoleWrite("Type of row: 2 - Primary and spouse only" & @CRLF)
   
   ; Primary part
   EnterAdult(0)
   ; Spouse part
   Send("{TAB 3}")
   EnterAdult(4)
   
   ; Move to Get a Quote button
   AdlibEnable("myadlib")
   If $AbortRow = "False"  Then ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   If $AbortRow = "False"  Then ConsoleWrite("Move to Choose Plans page." & @CRLF)
   Sleep(750)
   
   
  Case $TypeOfRow = 3; Primary, Spouse, and 1 child
   ConsoleWrite("Type of row: 3 - Primary, Spouse, and 1 child" & @CRLF)

   ; Primary part
   EnterAdult(0)
   ; Spouse part
   Send("{TAB 3}")
   EnterAdult(4)
   ; Child 1 part
   Send("{TAB 3}")
   EnterKid(1)
   
   ; Move to Get a Quote button
   AdlibEnable("myadlib")
   If $AbortRow = "False"  Then ControlClick("Rate Calculator", "", "[TEXT:Get A Quote]")
   If $AbortRow = "False"  Then ConsoleWrite("Move to Choose Plans page." & @CRLF)
   Sleep(750)

there are over 30 different cases....

in the adlib handler, I set Abortrow="True"

at the end, I adlibdisable()

the sleep(750) is there because...

The surprising answer to my previous post is:

Whereever you are in the code, between 0 and 250MS AFTER the error occurs, you'll branch to adlib and return

So there is no telling WHERE you leave from, or return to

THAT is unstable....

There really needs to be a way to branch TO a specific location, somehow

Everseeker

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...