Jump to content

(SOLVED)Calling Function That Calls Original Function


Recommended Posts

18 minutes ago, Dgameman1 said:

Not sure why you don't just use a loop but here you go

Go()

Func Go()
    ;DoStuff
    ReGo()
EndFunc   ;==>Go

Func ReGo()
    Go()
EndFunc   ;==>Re-Go

 

Ok so there is a better way? if so how would I do this "loop" I don't want it to be a while 1 infinite loop because the func go() checks to see if a variable has changed or not before it runs itself all of the way... "however I need it to for sure run the first part even if that variable has not changed..."

Link to comment
Share on other sites

21 minutes ago, InunoTaishou said:

Post some more code, a better example of what you're trying to accomplish, because I don't understand.

Putting a loop in the Go function that calls Go would be more effective.

Here is a retry at the code Will that work?

 

Go()

Func Go()
Do
;Do Stuff

If $Stop_Submit = 0 Then
;Do More Stuff
Else

Endif

$rand = Random(800, 1150)
$PIIM = ($rand * 60 * GUICtrlRead($Post_Interval_In_Minutes)) ; PIIM = Park Interval In Minutes Use RAND for variation so Server Time is Limited
$PIIMR = $PIIM / 60000 ; PIIMR = Park Interval In Minutes Recalculated (converted to minutes)
$continue = MsgBox(4, "Continue?", "Click NO To Stop Submission Proccess or Click YES To Continue Submitting . This Box Will Timeout And Continue Submitting In " & $PIIMR & " Minutes", $PIIMR)
If $continue = 7 Then
$Stop_Submit = 1
Else

EndIf

Until $Stop_Submit = 1
Endfunc

 

18 minutes ago, JohnOne said:

What you have there is called recursion. I'm sure it has its place, but I've never needed it.

If you use recursion wrong it will crash your script eventually, or AutoIt will end it.

Thanks for the terminology :D I think I found a simpler way.... :D That code up there is what I think might work... can either of you confirm for me?

Edited by rm4453
Fixed spelling error
Link to comment
Share on other sites

Nasty. It would work but idk why you wouldn't just return. I can't make your example work since I don't have your variables and the GUI, but maybe this will give you an idea.

Go()

Func Go()
    Local $iLoops = 0
    Local $iTimer = TimerInit()
    While (True)
        ConsoleWrite("Currently looped count: " & $iLoops & @LF)

        If (TimerDiff($iTimer) > 3000) Then
            If (MsgBox(4, "Continue?", "Would you like to continue looping?") = 7) Then
                Return ConsoleWrite("Finally exited that loop!" & @LF)
            Else
                ConsoleWrite("User opted to continue looping >.<" & @LF)
                $iTimer = TimerInit()
            EndIf
        EndIf

        Sleep(200)
        $iLoops += 1
    WEnd
EndFunc

 

Link to comment
Share on other sites

1 minute ago, InunoTaishou said:

Nasty. It would work but idk why you wouldn't just return. I can't make your example work since I don't have your variables and the GUI, but maybe this will give you an idea.

Go()

Func Go()
    Local $iLoops = 0
    Local $iTimer = TimerInit()
    While (True)
        ConsoleWrite("Currently looped count: " & $iLoops & @LF)

        If (TimerDiff($iTimer) > 3000) Then
            If (MsgBox(4, "Continue?", "Would you like to continue looping?") = 7) Then
                Return ConsoleWrite("Finally exited that loop!" & @LF)
            Else
                ConsoleWrite("User opted to continue looping >.<" & @LF)
                $iTimer = TimerInit()
            EndIf
        EndIf

        Sleep(200)
        $iLoops += 1
    WEnd
EndFunc

 

I kind of understand that... however I am using a Somewhat Random time that is based off of a user selection for the timeout interval "how long the message box will essentially "pause" the script while allowing the user to still stop it if need be..." That way It will only submit the information to the server when they need it to instead of over polling my system and their system... Your code is kind of confusing to me if you could explain to me how it works that would be very much appreciated! Thanks! (I also want them to be able to see when the next submission will occur so I will be including a timestamp for next submission)

Link to comment
Share on other sites

All my code does is infinitely loop (While (True)) until the user clicks "No" on the message box. I didn't want the MessageBox to pop up every milisecond so I put it on a timer for every 3 seconds. (TimerDiff($iTimer) > 3000, so when the difference between the current time and when the timer was started is greater than 3000.)

Once you hit "No" on the MessageBox then I return. This might be the part where you do your Stop and Submit stuff. If you hit "Yes" (to continue) then I reset the timer so you get another MessageBox in 3 minutes.

Link to comment
Share on other sites

6 minutes ago, InunoTaishou said:

All my code does is infinitely loop (While (True)) until the user clicks "No" on the message box. I didn't want the MessageBox to pop up every milisecond so I put it on a timer for every 3 seconds. (TimerDiff($iTimer) > 3000, so when the difference between the current time and when the timer was started is greater than 3000.)

Once you hit "No" on the MessageBox then I return. This might be the part where you do your Stop and Submit stuff. If you hit "Yes" (to continue) then I reset the timer so you get another MessageBox in 3 minutes.

Okay that makes a little bit more sense... Any way you could adapt it for me so I can see how I would implement it?

$PIIM = Park Interval In Minutes (How long to essentially stop the script and wait)

$Post_Interval_In_Minutes = How Long In Minutes The User Wanted To Have The Script Wait

$PIIM is calculated by getting a random number between 800 (aka 800 milliseconds) and 1150 (aka 1150 milliseconds) and multiplying by 60 and $Post_Interval_In_Minutes

$PIIMR is calculated by dividing PIIM by 60000 (60000 milliseconds = 1 minute)

Link to comment
Share on other sites

ERROR! I accidentally messed up my code! LOL Let me repost sorry guys... put actions in wrong area... XD *A DERPA DERP*

 

Go()

Func Go()
Do
;Do Stuff

If $Stop_Submit = 0 Then
    ;Do More Stuff

    $rand = Random(800, 1150)
    $PIIM = ($rand * 60 * GUICtrlRead($Post_Interval_In_Minutes)) ; PIIM = Park Interval In Minutes Use RAND for variation so Server Time is Limited
    $PIIMR = $PIIM / 60000 ; PIIMR = Park Interval In Minutes Recalculated (converted to minutes)
    $continue = MsgBox(4, "Continue?", "Click NO To Stop Submission Proccess or Click YES To Continue Submitting . This Box Will Timeout And Continue Submitting In " & $PIIMR & " Minutes", $PIIMR)
    
        If $continue = 7 Then
        $Stop_Submit = 1
    Else

    EndIf

Else

Endif

Until $Stop_Submit = 1
Endfunc

Sorry bout that guys... I misplaced where the code should have gone :sweating:

Link to comment
Share on other sites

Something like this maybe

Go()

Func Go()
    Local $Post_Interval_In_Minutes = 1
    Local $Stop_Submit = False

    While (Not $Stop_Submit)
        ; Random number between 800 and 1150 * 60 * the minutes read from the GUI Control, then converted to minutes
        Local $rand = Random(800, 1150)
        Local $PIIM = ($rand * 60 * $Post_Interval_In_Minutes) ; PIIM = Park Interval In Minutes Use RAND for variation so Server Time is Limited
        Local $PIIMR = $PIIM / 60000 ; PIIMR = Park Interval In Minutes Recalculated (converted to minutes)

        If (MsgBox(4, "Continue?", "Click NO To Stop Submission Proccess or Click YES To Continue Submitting . This Box Will Timeout And Continue Submitting In " & $PIIMR & " Minutes", $PIIMR) = 7) Then
            $Stop_Submit = True
        Else
            ConsoleWrite("Continue Submitting" & @LF)
        EndIf
    WEnd

    ConsoleWrite("Stop Submitting" & @LF)
EndFunc   ;==>Go

You've got the wrong Timeout for MsgBox though.

Link to comment
Share on other sites

5 minutes ago, InunoTaishou said:

Something like this maybe

Go()

Func Go()
    Local $Post_Interval_In_Minutes = 1
    Local $Stop_Submit = False

    While (Not $Stop_Submit)
        ; Random number between 800 and 1150 * 60 * the minutes read from the GUI Control, then converted to minutes
        Local $rand = Random(800, 1150)
        Local $PIIM = ($rand * 60 * $Post_Interval_In_Minutes) ; PIIM = Park Interval In Minutes Use RAND for variation so Server Time is Limited
        Local $PIIMR = $PIIM / 60000 ; PIIMR = Park Interval In Minutes Recalculated (converted to minutes)

        If (MsgBox(4, "Continue?", "Click NO To Stop Submission Proccess or Click YES To Continue Submitting . This Box Will Timeout And Continue Submitting In " & $PIIMR & " Minutes", $PIIMR) = 7) Then
            $Stop_Submit = True
        Else
            ConsoleWrite("Continue Submitting" & @LF)
        EndIf
    WEnd

    ConsoleWrite("Stop Submitting" & @LF)
EndFunc   ;==>Go

You've got the wrong Timeout for MsgBox though.

Saw that and am fixing it Thanks ! I will look at your code and see if I can figure it out and all that Thanks so much! :lmao:

Link to comment
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
 Share

×
×
  • Create New...