kylet90

Recursion Issue

4 posts in this topic

Hi,

I am trying to use the following script which, after running overnight I found gives a "Recursion error - limit reached" type of error.

This is the code I am trying to use:

Loop()

Func Loop()
; Check if Powerpoint is running
If ProcessExists("powerpnt.exe") Then 
    Sleep(15000)
    Call("Loop")
Else
    Run("C:\\scripts\\open.bat", "", @SW_HIDE)
    Sleep(10000)
    Send("U")
    Sleep(8000)
    Send("{F5}")
    Call("Loop")
    EndIf
    
    EndFunc     ;Loop

I found Recursion in the Wiki which gives an example on how it works, and how to work around it - but my script does not have any +1 type counter in there which i can implement an If x(limit) reached then Return ;          

  ----Source:
https://www.autoitscript.com/wiki/Recursion

Any help would be really appreciated. 

Kyle

Share this post


Link to post
Share on other sites



Recursion is not needed, you just have to use a loop  (while...wend or do...until)

While 1
    Loop()
WEnd

Func Loop()
    If ProcessExists("powerpnt.exe") Then 
        Sleep(15000)
    Else
        Run("C:\scripts\open.bat", "", @SW_HIDE)
        Sleep(10000)
        Send("U")
        Sleep(8000)
        Send("{F5}")
    EndIf
EndFunc

 

Share this post


Link to post
Share on other sites

Perfect - thanks!

Share this post


Link to post
Share on other sites

Hi.

I can't see, why you use a separate function?

While 1
    If ProcessExists("powerpnt.exe") Then
        Sleep(15000)
    Else
        Run("C:\scripts\open.bat", "", @SW_HIDE)
        Sleep(10000)
        ; a winwait() / winwaitactive() / winactivate() might be a more robust approach
        Send("U")
        Sleep(8000)
        Send("{F5}")
    EndIf
WEnd

 

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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