Jump to content
rm4453

(SOLVED)Calling Function That Calls Original Function

Recommended Posts

rm4453

How would I get this code to work? If not possible/If there is a better way... How would I do it? I can't seem to get it to work properly...

 

Func Go()
;Do stuff
Re-Go()
EndFunc

Func Re-Go()
Go()
EndFunc

 

Edited by rm4453
(Solved)

Share this post


Link to post
Share on other sites
Dgameman1

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

 

Share this post


Link to post
Share on other sites
rm4453
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..."

Share this post


Link to post
Share on other sites
InunoTaishou

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.

Share this post


Link to post
Share on other sites
rm4453
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

Share this post


Link to post
Share on other sites
InunoTaishou

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

 

Share this post


Link to post
Share on other sites
rm4453
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)

Share this post


Link to post
Share on other sites
InunoTaishou

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.

Share this post


Link to post
Share on other sites
rm4453
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)

Share this post


Link to post
Share on other sites
rm4453

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:

Share this post


Link to post
Share on other sites
InunoTaishou

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.

Share this post


Link to post
Share on other sites
rm4453
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:

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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hello
      Can we pause and resume the download in the InetGet function?
      If is possible, what is the solution please?
      I used this code To manage the download

      #include <INet.au3> func _downloader($name, $linc, $filepath, $RTLF = false, $link = false) global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link) global $path = $filePath $labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20) global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20) global $Progress = "" global $sText = ""     For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.         $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case). next global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20) _GUICtrlEdit_SetReadOnly(-1, true) GUIStartGroup("") global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20) GUIStartGroup("") $button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01) $iIndex = 0 global $Target global $url GUIStartGroup("") global $Progress = GUICtrlCreateProgress(50, 90, 150, 20) global $Target = $filepath global $url = $linc global $path = $filepath global $hDownloadNo = _RSMWare_GetData($url, $Target) global $status = false AdlibRegister("SetProgress") global $onprogress = false, $curent = false GUISetState(@sw_Show) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button $asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?") if $asc = 6 then AdlibUnRegister("SetProgress") GUIDelete() If $hDownloadNo <> 0 Then InetClose($hDownloadNo) exitLoop endIf EndSwitch if $status = -1 then $status = 0 $hDownloadNo = _RSMWare_GetData($url, $Target) $onprogress = false $curent = false elseIf $Status = 1 then $status = $path GUIDelete() AdlibUnRegister("SetProgress") exitLoop endIf WEnd return $status endFunc Func _RSMWare_GetData($url, $Target) Local $hDownload = InetGet($url, $Target, 1, 1) Return $hDownload EndFunc ;==>_RSMWare_GetData Func SetProgress() Local $state If $hDownloadNo <> 0 Then $state = InetGetInfo($hDownloadNo) If @error = 0 Then $infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB " $onprogress = Round(Ceiling(($state[0] / $state[1]) * 100)) if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then if $onProgress <= 0 then $onProgress = 0 GUICtrlSetData($Progress, $onProgress) GUICtrlSetData($labelTxt0, $infor) GUICtrlSetData($labelTxt2, $onProgress & "%") if _isChecked($beep) then if $onprogress > $curent then beep((100 + $onprogress * 20), 100) $curent = $onprogress endIf endIf endIf If $state[2] Then If $state[3] Then InetClose($hDownloadNo) $status = 1 else InetClose($hDownloadNo) $status = -1 endIf endIf EndIf endIf EndFunc ;==>SetProgress
    • VollachR
      By VollachR
      Hi,
      I'm looking for a way to take a number value from a Row2 of a 2D array and according to this check if files that appear in rows 3-11 in the array exists.
      For example, if the number in Row2 is 5 I need to check for the files in Row 3-6 only, if it is 6 than rows 3-7 and so on.
      I thought on using a FOR loop but I have very little experience with those.
      Can you suggest the best way to do what I need?
      BTW, the files in Rows 3-11 will usually have blank value for any row above the number in Row2 (e.g. Row2 = 5 so Rows3-6 will have values but 8-11 be empty), The values I need are in Column 1 of the array, the name of the key from the INI file that the array was created from is in Column 0.
      Full Example:
      Row2 of Array:
      Col0 = Games# - Col1 = 5
      Rows3-6
      Col0 = Exe2 - Col1 = Path To File
      Col0 = Exe3 - Col1 = Path To File
      Col0 = Exe4 - Col1 = Path To File
      Col0 = Exe5 - Col1 = Path To File
      I need that if Row2 is 5 to check these above for rows if the file exists, if it was 6 then the next row as well and so on up until number 10 in Row2 as it can't go above 10.
      So basically for whatever number in Row2 from 2-10 need to check 1-9 rows from 3-11 to see if the files in Col1 exists and if any of them don't exist it should call a function that shows an error message.
      I'm pretty sure I have the first line of the for look correct:
      For $i = 1 To $aAIO[2][1] Just not sure how to continue from there, also not sure if $i should be equal 1 or 2.
      Help will be appreciated.
    • VollachR
      By VollachR
      Hi,
      I've written a specialty INI file editor for a specific set of INI files related to a bigger script I'm working on.
      I'm trying to create a verification script that checks the ini files structure and format and gives an error if they are not in expected format.
      What I did so far is create a couple of custom arrays, each with the list of Sections expected in the files and I use IniReadSectionNames in order to read the sections from the selected INI file and compare it to the array.
      It works fine, excepts it only gives an error if one or more of the sections in the custom array is missing, if they all exist but there are other additional sections that shouldn't be there it doesn't give an error and continue to open the editor screen.
      Here are the relevant part of my script:
      The Custom Verification Arrays:
      ;Creating Arrays for INI Verification Global $aSettingsVerify[7] $aSettingsVerify[1] = "Conversion" $aSettingsVerify[2] = "AIO" $aSettingsVerify[3] = "Data" $aSettingsVerify[4] = "Redist" $aSettingsVerify[5] = "Split" $aSettingsVerify[6] = "Autorun" Global $aDataVerify[6] $aDataVerify[1] = "Compression" $aDataVerify[2] = "Exclude" $aDataVerify[3] = "LangExclude" $aDataVerify[4] = "PreCommands" $aDataVerify[5] = "PostCommands" The IniReadSectionNames verification part:
      Case $OK If StringInStr($ActiveConfig, "Settings.ini") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aSettingsVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) SettingsGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf If StringInStr($ActiveConfig, "Data") Then $CheckArray1 = IniReadSectionNames($ActiveConfig) $CheckArray2 = _ArrayCompare($aDataVerify, $CheckArray1) $CheckArray3 = UBound($CheckArray2, 1) If $CheckArray3 = 1 Then GUIDelete($ConfigStart) DataGUI() EndIf If $CheckArray3 > 1 Then WrongIni() EndIf EndIf The Function that performs the compare: (Found it in another thread on this forums somewhere by using Google Search)
      ;Compares Imported INI file with the Verification array Func _ArrayCompare(ByRef $a1, ByRef $a2) Local $nOldSize = UBound($a2) Local $a3[$nOldSize], $nNewSize = $nOldSize For $i = 0 To UBound($a1) - 1 For $j = 0 To $nOldSize - 1 If Not $a3[$j] And ($a1[$i] = $a2[$j]) Then $a3[$j] = 1 $nNewSize -= 1 EndIf Next Next Local $a4[$nNewSize], $j = 0 For $i = 0 To $nOldSize - 1 If Not $a3[$i] Then $a4[$j] = $a2[$i] $j += 1 EndIf Next Return $a4 EndFunc ;==>_ArrayCompare  
      Any way to make a check if there are sections other than the ones in the Verification Array and produce an error?
      Thanks
×