Jump to content

For Next Error


hcI
 Share

Recommended Posts

Hello ! First, i'm sorry for my bad english.

So, let's explain. I'm making a little game with AutoIt and, i have some bugs

I just want to say that  $lb_p_sc  is a label who display scores and  $w  have the actual score awaiting to be displayed 1 by 1 every 1/5 seconds (200ms)

here is my code :

Func sys_3($x)
    If $k = 1 Then
        If $x = 0 Then
            $w = $q
            While $w > 0 ; While works perfectly
                Sleep(200)
                $v = GUICtrlRead($lb_p_sc)
                GUICtrlSetData($lb_p_sc, $v + 1)
                $w -= 1
            WEnd
        ElseIf $x = 1 Then
            $w = $r
        ElseIf $x = 2 Then
            $w = $s
        ElseIf $x = 3 Then
            $w = $u
        EndIf
    EndIf
EndFunc

From there, no problem ! Everything work. But when i change While - WEnd to For - Next  everyting are going wrong.. :(

Here is the code with Next - For :

Func sys_3($x)
    If $k = 1 Then
        If $x = 0 Then
            $w = $q
            For $w To 0 Step -1
                Sleep(200)
                $v = GUICtrlRead($lb_p_sc)
                GUICtrlSetData($lb_p_sc, $v + 1)
            Next
        ElseIf $x = 1 Then
            $w = $r
        ElseIf $x = 2 Then
            $w = $s
        ElseIf $x = 3 Then
            $w = $u
        EndIf
    EndIf
EndFunc

And when i try to execute that, it  says so much error but the problem from For - Next (by deduction)

So here's the errors marked  in the console:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3" /UserParams    
+>22:38:27 Starting AutoIt3Wrapper v.16.612.1119.0 SciTE v.3.5.4.0   Keyboard:0000040C  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:040C)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\XXXX\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\XXXX\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.2)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(227,11) : error: syntax error
            For $w To
            ~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(227,14) : error: Statement cannot be just an expression.
            For $w To 0
            ~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(227,23) : error: Statement cannot be just an expression.
            For $w To 0 Step -1
            ~~~~~~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(231,4) : error: missing EndIf.
            Next
            ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(225,17) : REF: missing EndIf.
        If $x = 0 Then
        ~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(231,4) : error: missing EndIf.
            Next
            ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(224,16) : REF: missing EndIf.
    If $k = 1 Then
    ~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(231,4) : error: syntax error
            Next
            ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(231,4) : error: Statement cannot be just an expression.
            Next
            ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(232,3) : error: Statement cannot be just an expression.
        ElseIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(232,17) : error: syntax error
        ElseIf $x = 1 Then
        ~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(234,3) : error: syntax error
        ElseIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(234,3) : error: Statement cannot be just an expression.
        ElseIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(234,17) : error: syntax error
        ElseIf $x = 2 Then
        ~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(236,3) : error: syntax error
        ElseIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(236,3) : error: Statement cannot be just an expression.
        ElseIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(236,17) : error: syntax error
        ElseIf $x = 3 Then
        ~~~~~~~~~~~~~~^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(238,3) : error: syntax error
        EndIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(238,3) : error: Statement cannot be just an expression.
        EndIf
        ^
"C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3"(239,2) : error: Statement cannot be just an expression.
    EndIf
    ^
C:\Users\XXXX\Desktop\Projets termines\Autoit\tactical stairs\tactical stairs.au3 - 18 error(s), 0 warning(s)
!>22:38:27 AU3Check ended. Press F4 to jump to next error.rc:2
+>22:38:27 AutoIt3Wrapper Finished.
>Exit code: 2    Time: 0.5242
 

I don't understand why For - Next is making so much error.

If someone can tell why (and how to make it right?)

Thanks

Link to comment
Share on other sites

  • Developers

Well the syntax for the For statement is wrong and should be : For $w = $q to 0 step -1
Just check the helpfile for proper syntax explanation.

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Don't blame the writer of the helpfile page for your own mistakes. ;)

The examples are pretty clear.

Jos

Edited by Jos
Typo

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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