Sign in to follow this  
Followers 0
trademaid

problem with loops

6 posts in this topic

If get the following error message

"D:\4\autoit\tradebox1i.au3 (56) : ==> "Next" statement with no matching "For" statement.: "

I am trying to make a loop, have tried for, while and do. Please see section of code that says

; *** while $sysloop < 5

;****For $sysloop = 0 to 4

;**do

and

;**until $sysloop>4

;****next

; ***wend

the input file d:\4\pr3.txt contains the following

20080423 120000 PLATINUM 4 704.60 ER

20080423 121000 BREAKOUT -2 701.60 ES

20080423 124500 Retracement 7 706.60 ER

20080423 150000 PRER 0 702.60 ER

20080423 150105 TURBO 11 701.20 ER

;filename contains...

; date, time, system, mp, price , contract

#include <String.au3>

#include <file.au3>

#include <array.au3>

$client="Striker** " & @CRLF

Dim $System[6]

Dim $Sysflag[6]

$system[0]="prER"

$system[4]="Breakout"

$system[2]="Retracement"

$system[3]="PLATINUM"

$system[1]="Turb-o"

$sys0flag=-1

$sys1flag=-1

$sys2flag=-1

$sys3flag=-1

$minus=""

$sysloop=0

$y=0

for $y=0 to 5

$sysflag[$y]=-1

Next

$contractER=""

$ER="0"

$EMD="0"

$ES="0"

$L=0

Do

$filenme=("d:\4\pr3.txt")

$message = ""

Dim $aRecords

If Not _FileReadToArray($filenme,$aRecords) Then

MsgBox(4096,"Error", " Error reading log to Array error:" & @error)

Exit

EndIf

For $x = $aRecords[0] to 1 step -1

$ssplit=StringSplit ( $aRecords[$x], " " )

if _ArraySearch($system,$ssplit[3],0,0,0,false) <> -1 then ; if the aray contains a traded system

$minus=""

if $ssplit[4] >=0 then $minus="+"

$message=$message & $ssplit[1] & " " & $ssplit[2] & " " & $ssplit[3] & _StringRepeat(" ",12-round(1*StringLen($ssplit[3]),0) ) & @TAB & $minus & $ssplit[4] & " ; " &$ssplit[5] & " : " & $ER & ", " & $ES & " "& $EMD & @lf

; *** while $sysloop < 5

;****For $sysloop = 0 to 4

;**do

if $sysflag[$sysloop]=-1 and $ssplit[3]=$system[1] and $ssplit[6] ="ER" then ; if it is a the last referance to a system (flat not zero)

$contractER=$contractER + $ssplit[4] ; add the amount of contracts

;$sys1flag=0 ;reset the flat, so dont look any more for this system

$sysflag[$sysloop]=0

$sysloop=$sysloop+1;

;**until $sysloop>4

;****next

; ***wend

EndIf

endif

Next

$message=$message & " total of " & $contractER & @LF

SplashTextOn("YYYYMMDD TIME System name , Contract , Time , Po$$$stion , Quatnity#" & $client, $message, -1, -1+250, -1+1, -1+1, 16+4, "courier",11,100)

sleep(2500)

$L=$L+1

UNTIL $L>1

Share this post


Link to post
Share on other sites



Where you see ";;;;;;;;;;" I've removed some of your code for better presentation within the forum.

using the indentations - can you see where your problem is?

It appears as if you are attempting to end that loop one line too soon.

You need to include the EndIf.

For $x = $aRecords[0] To 1 Step -1
    $ssplit = StringSplit($aRecords[$x], " ")
    If _ArraySearch($System, $ssplit[3], 0, 0, 0, False) <> -1 Then
        $minus = ""
        If $ssplit[4] >= 0 Then $minus = "+"
        $message = "" ;;;;;;;;;;

        ; *** while $sysloop < 5
        ;****For $sysloop = 0 to 4
        ;**do
        If $Sysflag[$sysloop] = 0 ;;;;;;;;;;

            $sysloop = $sysloop + 1;
            ;**until $sysloop>4
            ;****next
            ; ***wend
        EndIf
    EndIf
Next

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I should also add that you might want to download/install the full version of the SciTE Editor and use "Ctrl-T" to bid the "tidy" software.

Perhaps you already did this and your post just does not reflect it because you did not know about the AutoIt tags that you can use when posting code - they help keep the indentations and color code the info for an easier read.

I use the "Insert Special Item" drop down menu to insert these tags into a post. Others do it other ways.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

A big thanks to the two people who replied. Autoit rocks!

Share this post


Link to post
Share on other sites

A big thanks to the two people who replied. Autoit rocks!

I know that I am senile - but now I'm a Schizoid as well :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I am running a script, say msgbox(....) under terminal server

It only runs on one rdp session. So even if user2 runs it the message box appears (and the script runs) only under user 1

any solutions?

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
Sign in to follow this  
Followers 0