Jump to content

Won't recognise my loop


Recommended Posts

Hi,

I'm running a script that had A Do Until statement in it. However every time I ran it, I got an error message saying:

"Error: "Until" statement with no matching "Do" statement."

I tried replacing the loop with a While..Wend statement but then got this error message:

"Error: "Wend" statement with no matching "while" statement."

Why is it not recognising my loops, and is there anyway of me linking them manually?

Thanks for the help!

Link to comment
Share on other sites

Hi,

I'm running a script that had A Do Until statement in it. However every time I ran it, I got an error message saying:

"Error: "Until" statement with no matching "Do" statement."

I tried replacing the loop with a While..Wend statement but then got this error message:

"Error: "Wend" statement with no matching "while" statement."

Why is it not recognising my loops, and is there anyway of me linking them manually?

Thanks for the help!

That error is often misleading. Instead of looking for the missing Do or While, look for something like a missing End statement. Usually it's EndIf but it could also be EndSwitch or EndSelect.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

We can't pinpoint whats going on in the code unless you show it. Essentially the code would be,

Do

code here

code here

Until code here

for anything more clear we need to see your code.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

I have got a hint for you in order to: 1) fix this problem, 2) fix this problem in the future and 3) code cleaner

Consider this code:

While 1
If 1 Then
Do
Select 1
Case 2
MsgBox(0, "", "")
Until 0
EndIf
WEnd

Now, that isn't terribly easy to read. Now, take a look at this:

While 1
    If 1 Then
        Do
            Select 1
                Case 2
                    MsgBox(0, "", "")
        Until 0
    EndIf
WEnd

Not only is this easier to read and understand, we can also immediately see we're missing something: EndSelect.

You should try indenting your script like so, it will indicate you where your error is, and if you do so consistently in the future, your scritps will be easier to read, easier to modify later on, and small errors can be found more easially. It has become a second nature to me.

Edited by TomZ
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...