Jump to content

Recommended Posts

Posted

I am trying to write a script that will run two loops consecutively.

Example would be something like:

While1
   repeat 20x
Goto While2

While2
   repeat 20x
Goto While1

Any advice is appreciated.

 

  • Solution
Posted (edited)

I'm sure there is a method that can suit your needs.

Will both loops always run the same number of times?  If so, and depending on how complicated the activities are for each loop, you could create two functions for each "task" and then just run them both in sequence.  

For example

Global $iLoopCount = 20

For $iX = 1 to $iLoopCount
    TaskA($iX)
    TaskB($iX)
Next

Func TaskA($iX)
    ConsoleWrite("Task A: " & $iX & " of " & $iLoopCount & " iterations" & @CRLF)
    ;do stuff
EndFunc

Func TaskB($iX)
    ConsoleWrite("Task B: " & $iX & " of " & $iLoopCount & " iterations" & @CRLF)
    ;do stuff
EndFunc

We may ask you to share some code or what you are trying to accomplish to better understand how to help.

 

edit:

Actually, I think I misread/misunderstood what you want to do.  There is nothing stopping you from having one loop, then another.  Use a FOR LOOP if you want to run a loop exactly X many times.

For $iX = 1 to 20
    ;do stuff
Next

For $iX = 1 to 20
    ;do other stuff
Next

 

Edited by spudw2k
  • Moderators
Posted

Moved to the appropriate AutoIt General Help and Support forum, as the AutoIt Example Scripts forum very clearly states:

  Quote

Share your cool AutoIt scripts, UDFs and applications with others.


Do not post general support questions here, instead use the AutoIt Help and Support forums.

Expand  

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

Thank you spudw2k! Both of those examples are exactly what I was looking for.  I am new to this forum and do not know how to post my script but....

What I was after looks something like this:


Global $Paused, $Runner
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")


While 1
For $iX = 1 to 20
    msgbox(1,"Title","1") ; This is an inline comment
Next

For $iX = 1 to 20
    msgbox(1,"Title","2") ; This is an inline comment
 Next
Wend
Exit

 Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

  • Moderators
Posted
  On 5/19/2022 at 6:37 AM, Rubbadubbadoo said:

I am new to this forum and do not know how to post my script

Expand  

When you post code in future please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

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