Jump to content

Recommended Posts

Posted

I have a script that automatically runs through realtime report screens on network stats. It is very visible as it sits on a plasma screen in a common area for all to view. The problem is -- periodically the macro gets out of sync.

I can detect the error message box from the program I'm running the script against and handle that - I can reset the variables and such for the script -- but I'm coming up with a brain block on how to restart the script from a certain point. Its not at the begining of the script its about 100 lines in. This would be perfect for a simple GoTo -- but I see its no longer supported ??

Any suggestions ??

thanks

Posted

How about this?

(Pseudo Code)

;STart of Script

$ran = INIRead($INI, "Ran_already", "Ran", 0)

If not $ran = 1 Then

IniWrite($INI, "Ran_already", "Ran", 1)

;Code as if the Script didn't crash

EndIf

;Next Lines after the first 100

If Script performs OK

IniWrite($INI, "Ran_already", "Ran", 0)

EndIf

Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer
Posted

thanks for the fast reply

that would work to not rerun the begining of the file -- How would I restart the script? would it be a run command and then exit the current script ?? (doesn't seem clean that way ?)

here is the basic layout

Start --

basic entry code , login , etc (about the first 100 lines)

do --- this is where I'd like to restart

code takes about 1hour to run through so

until looped 20 times

shutoff for the night

End ---

restarted with windows scheduler in the morning

Posted

Thanks :whistle:

While we were discussing -- I've nested the entire loop in another loop (whats another few lines of code) with the outer loop checking for errorcodes. In the error trap func I reset the params and exit the inner (first) loop - we'll see how it flys -- hopefully not like a wounded duck :dance:

thanks again

Posted

Don't know if this will help anyone -- but the nested Do Loops seems to work in trapping the error and then resetting from a given point to start the script over..

Thanks for the help :whistle:

$isError = 0

$LoopCount = 0

do ; error loop

do ; main loop

---- Lots of code here ----

If WinActive("Microsoft Internet Explorer") Then ; check for error dialog box

$isError = 1

WinActivate("Microsoft Internet Explorer")

Send ("{ENTER}") ; this closes the error message box

WinActivate ( <correct Window> ) ; go back to main window

sleep (500)

ExitLoop ; bail to reset variables and restart

EndIf

$LoopCount = $LoopCount + 1 ; increment counter if error not found

Until $LoopCount = 5 ; main loop

if $LoopCount = 5 Then ; really shut off cause I got all the way through without errors

ExitLoop

EndIf

if $isError = 1 then ; you got here with an error -- reset all variables and go back to the begining

$isError = 0

$LoopCount = 0

endif

until $LoopCount = 5 ; error loop

Exit

Posted

Use the [ CODE ] tags to post code

$isError = 0
$LoopCount = 0
Do; error loop
    Do; main loop
         - - - - Lots of code here - - - -
        If WinActive("Microsoft Internet Explorer") Then; check for error dialog box
            $isError = 1
            WinActivate("Microsoft Internet Explorer")
            Send("{ENTER}"); this closes the error message box
            WinActivate(<correct Window >); go back to main window
            Sleep(500)
            ExitLoop; bail to reset variables and restart
        EndIf
        $LoopCount = $LoopCount + 1; increment counter if error not found
    Until $LoopCount = 5; main loop
    
    If $LoopCount = 5 Then; really shut off cause I got all the way through without errors
        ExitLoop
    EndIf
    If $isError = 1 Then; you got here with an error -- reset all variables and go back to the begining
        $isError = 0
        $LoopCount = 0
    EndIf
    
Until $LoopCount = 5; error loop

Exit

Keeps the indentation of the Lines...

Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer
Posted

one way to handle errors is...

from help

RunErrorsFatal Sets if the script should terminate with a fatal error if a Run/RunWait function fails due to bad paths/file not found/Bad login IDs:

1 = fatal error (default)

0 = silent error (@error set to 1)

secondly you can put the program in the start-up folder and put in a line like this to run during the hours you wish

While @Hour >= 7 And @Hour < 17 Then
; place script here
Wend

hope those help

8)

NEWHeader1.png

Posted

then after handling the error... use this to "reset" or start again at the while loop

ContinueLoop

--------------------------------------------------------------------------------

Continue a While/Do/For loop.

ContinueLoop [level]Parameters

level [optional] The level of the loop to restart. The default is 1 (meaning the current loop).

Remarks

ContinueLoop will continue execution of the loop at the expression testing statement (that is the While, Until or Next statement).

8)

NEWHeader1.png

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...