rm4453

(SOLVED)Calling Function That Calls Original Function

13 posts in this topic

#1 ·  Posted (edited)

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



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

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

#6 ·  Posted (edited)

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

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

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

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

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

    • wakillon
      By wakillon
      SciTE Hopper : Jump to Any line by one click and many other helpfull functions !


      As Ashalshaikh suggested me after leaving me the task to continue >SciTE Hopper, i open a new Topic about it.
      It will be more easy for futures updates.

      Many helpfull functions in contextual menu.
      SciTE Hopper is now multipurpose.
      • Color Catcher added
      • BinaryToAu3Kompressor added
      • TinyAu3Search replaced by StringFinder
      • RegJumper added
      • Edit With SciTE added (available in Options)
      • SpecialCharactersViewer added (available in Tray menu)
      New Contextual Menu :

      For a right Click on a function :

      • Copy function name
      • Insert a function header
      • Cut function
      • Copy function
      • Delete function
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments

      For entire script :

      • Create a functions List
      • Create a variables List
      • Remove usseless Blank lines
      • Remove Debug lines ( all lines starting with ConsoleWrite or _ArrayDisplay )
      • Set AutoIt Code Layout
      • Remove Comments
      • ( Open in SciTE a ) Duplicate of current Script in Temp Dir
      • ( Open in SciTE a ) Duplicate of current Script in Same Dir
      • Explore Parent Script Folder
      • Copy Script name
      • Copy Script path
      • Find Unused Functions
      • Find Unused Variables
      • Set all functions in alphabetic order.( func headers and regions ( in fact, all lines between functions ) are not supported.)

      SciTE Editor New Contextual Menu if SciTE Hopper is added ( in Options ) to SciTE Editor :
      when you made a selection in SciTE Editor you can :

      • Open a Reg Key in Regedit using RegJumper
      • Open a Url in your default Browser
      • Search on google in your default Browser
      • Search on AutoIt Website in your default Browser
      Now Can be added to windows start (minimized)
      Options are available by Tray Menu.
      A double click on tray icon will open clipboard content to SciTE Editor ( Handy when you have copied some code from your browser )

      How to proceed for add SciTE Hopper to SciTE Editor :
      Run Scite Editor, run Scite Hopper ( compiled! ) go to Options and select Add/Remove to SciTE Tab. then click on Add button and it's done !
      Right click on SciTE Editor and choose SciTE Hopper in Contextual Menu for run it when you need it !
      Update of 07 Dec 2017
      TinyAu3Search is replaced by StringFinder

      Previous downloads : 1287
      Script and compiled version are available in the download section
       
      Thanks to Ashalshaikh, Melba23, Th3 MMA, Alzri2, taitel, Manadar, taz742, Yashield, Authenticity, Xenobiologist for their help
      and asdf8 for his >Includes Helper and azjio for his >FileSearch.

      Hope it help you and happy Scripting !

       
    • X_xkijux_x
      By X_xkijux_x
      Ok so im using this program. clarify for school. I would like to have a program that takes every word i type in microsoft word and searches on it in claryfi. is this possible. I would like to have the program not stopping me from typing more after that word. Like when i type a word it auto search it on clarify without making me stop typing and if i want to change i can do that and if im fine that word i can just keep typing and it will search after the next word. 
    • Miliardsto
      By Miliardsto
      Is this possible to make program works like in diagram? There is so much encryption methods and UDFs are they give security? If the $Address will be crypted with some encryption algorithm could be possible to get the value of $Address in easy way? Of course We know its easy too look into autoit code and get value of variable and so We dont want to anyone see $Address value - there are functions Could func1.au3, func2.au3.. be for example func1.php or other type of file? As we know .php files are unnable to see. For example func1 would be read by FileRead() and then Execute() Is this generally possible to do?
      Will it give secure?
      What do you think about? Maybe there is something wrong in this concept or missed.

    • JaredStroeb
      By JaredStroeb
      I need to open an application and send it keys in Session 0.  I have exe's working locally, I can see the application open in session 0 through interactive services, but my send commands do not go to the application.  The following article running-autoit-session-0, directs me to use ControlSend() however my application has no controls that can be identified by AutoIt v3 Window Info.  Get All Windows Controls also returned nothing for the application's handle.  
      What are my options?  
      Can this be done with AutoIt?
      Is there a different "relatively simple" library/tool to use? (I am familiar with C# if there is a viable library there )

       
    • nassausky
      By nassausky
      Hey all,
      Has anyone created any queries for youtube? I was thinking it might be something like this but can't quite figure it out:
      $oIE = _IECreateEmbedded() _IENavigate($oIE,"https://www.youtube.com") Local $oForms = _IETagNameGetCollection($oIE, "form") Local $sTxt = "" For $oForm In $oForms If $oForm.id = "masthead-search" Then $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id = "masthead-search-term" Then _IEFormElementSetValue($oInput, "cards") _IEFormSubmit($oForm) EndIf Next EndIf Next