mentalmummy Posted April 8, 2006 Share Posted April 8, 2006 First post, so hello I`ve been writing a basic program with AutoIt V3, a simple horse racing program to guess a likely winner. Everything works fine until it gets to this set of statements and then it stops saying it expected a "=" operator in assignment statement: For $n = 1 to $racers step +1 If $lifetimeaw[$n] = $lifetimeflatturf[$n] and $lifetimeaw[$n] = $lifetimejumps[$n] then $besttype[$n] = "all rounder" If $lifetimeaw[$n] > $lifetimeflatturf[$n] and $lifetimeflatturf[$n] >= $lifetimejumps[$n] then $besttype[$n] = "aw" If $lifetimeflatturf[$n] > $lifetimeaw[$n] and $lifetimeaw[$n] <= $lifetimejumps[$n] then $besttype[$n] = "F" If $lifetimejumps[$n] > $lifetimeflatturf[$n] and $lifetimeflatturf[$n] >= $lifetimeaw[$n] then $besttype = "J" Next But I can`t see anything wrong with it, although I am a newb to the language. All I am sure of is that it is something to do with the variables themselves. I`ll paste the full script at the end of this post in case it helps, this is a work in progress and obviously more data will be fed to the program but I am hoping that someone can help me figure this out. Thanks. And I hope no one minds me jumping right in with a question as my frst post! Full script: ; We must include the files needed to draw a GUI. #include <GUIConstants.au3> ; Set up the variables that will hold data about a race as input by the user ; Each variable below is an array allowing data entry for up to twenty horses ; This is a temporary variable that we will use to store stuff temporarily global $temp = "" ; This variable holds the type of race dim $racetype[20] ; This variable holds the points we give each horse dim $points[20] ; this variable will tell us which type of race this horse wins most often at dim $besttype[20] ; This variable holds a yes (Y) or no (N) answer to whether the current jockey has ridden this ; horse a lot in the past dim $regularjockey[20] ; This variable will hold a Y or N answer for whether the current jockey has regularly placed on this ; horse within the top five in races dim $topfivejockey[20] ; This holds the amount of wins a horse has ever had in flat turf races ; so $lifetimeflatturf[5] tells us how many wins on flat turf horse five has ever had dim $lifetimeflatturf[20] ; This holds the amount of wins a horse has ever had in jump races so that ; $lifetimejumps[4] tells us how many wins horse four has had in jump races dim $lifetimejumps[20] ; This holds the amount of wins a horse has ever had in Aw races so that ; $lifetimeaw[7] tells us how many wins horse seven has had in Aw races dim $lifetimeaw[20] ; This variable holds the name for each horse in the race. So $name[2] tells us the name ; of runner number two in the race. dim $name[20] ; $age holds the age for each horse so $age[10] tells us how old horse ten is in years dim $age[20] ; Here we get a name from the user by which they can identify the race such as "3.30 at kempton". $racename = InputBox ( "Name of the race", "Please give me a name for the race and I will use this when displaying or saving results for you. Something like 3.30 AT HAYDOCK for example." ) ; now we find out how many horses are entered to run in the race $racers = InputBox ( "Number of entrants in race?", "Please type in numbers how many horses are in the race" ) ; lets get the type of race $temp = InputBox ( "Type of race?", "Is this race a flat race (F) , All Weather (AW) or a jump race (J)?" ) for $n = 1 to $racers step +1 $racetype[$n] = $temp Next ; Here we get the name for each horse For $n = 1 to $racers step +1 $temp = "Please type in the name of runner number " & $n & " and press ENTER on keyboard when ready to enter the name of the next runner." $name[$n] = InputBox ( "What is the horses name? Please note it is easiest to enter the names in the order they are listed in your race guide.", $temp ) Next ; Now we get additional details about each runner For $n = 1 to $racers step +1 ; let us get the age of horse[$n] $temp = "What is the age of runner " & $name[$n] $age[$n] = InputBox ( "Age of runner" & $n, $temp ) ; let us now get the amount of lifetime flat turf wins the horse has had $lifetimeflatturf[$n] = InputBox ( "Amount of flat turf wins?", "Please enter the lifetime amount of flat turf wins for " & $name[$n] & "?" ) ; we now get the amount of lifetime jump wins for the horse $lifetimejumps[$n] = InputBox ( "Amount of jump wins?", "Please enter the lifetime amount of wins for " & $name[$n] & "?" ) ; let us now get the amount of all weather wins the horse has had $lifetimeaw[$n] = InputBox ( "Amount of all weather (AW) wins?", "Please enter the lifetime amount of all weather (AW) wins for " & $name[$n] & "?" ) ; find out if the current jockey has ridden this horse quite a few times ; if yes then find out if this jockey regularly gets this horse within the top five finishers $regularjockey[$n] = InputBox ("Regular jockey?", "Has " & $name[$n] & "been ridden by the current jockey regularly? Look in the list of the races it has entered and decide. Type Y for YES or N if it is not a jockey used to this horse." ) If $regularjockey[$n] = "y" Then $topfivejockey[$n] = InputBox ("Regularly in top five with current jockey?", "Has " & $name[$n] & " been mostly within the top five when ridden by the current jockey?" ) ElseIf $regularjockey[$n] = "n" then $topfivejockey[$n] = "n" EndIf Next ; Now we figure out what type of race the horses are best at from AW, FLAT or JUMP and ; store this in $besttype For $n = 1 to $racers step +1 If $lifetimeaw[$n] = $lifetimeflatturf[$n] and $lifetimeaw[$n] = $lifetimejumps[$n] then $besttype[$n] = "all rounder" If $lifetimeaw[$n] > $lifetimeflatturf[$n] and $lifetimeflatturf[$n] >= $lifetimejumps[$n] then $besttype[$n] = "aw" If $lifetimeflatturf[$n] > $lifetimeaw[$n] and $lifetimeaw[$n] <= $lifetimejumps[$n] then $besttype[$n] = "F" If $lifetimejumps[$n] > $lifetimeflatturf[$n] and $lifetimeflatturf[$n] >= $lifetimeaw[$n] then $besttype = "J" Next ; Now we calculate the horses chances with the highest points meaning the best chance ; of wiining For $n = 1 to $racers step +1 ; award 3 points if the horse is best at this type of race ; or 2 if it is an allrounder if $besttype[$n] = $racetype[$n] then $points[$n] = $points[$n] +3 if $besttype[$n] = "all rounder" then $points[$n] = $points[$n] +2 ; award 3 points if the rider has regularly ridden the horse within the top five if $regularjockey[$n] = "y" and $topfivejockey[$n] = "y" then $points[$n] = $points[$n] +3 Next ; now write a text file to the desktop named after the race and with these details inside $file = FileOpen("C:\race result.txt", 2) FileWriteLine ( $file, "Predictive result for the race " &$name FileWriteLine ( $file, "The horse with the highest score is the probable winner" ) For $n = 1 to $racers step +1 FileWriteLine ( $file, "The horse called " & $name[$n] & " scores " & $points[$n] & "points." ) Next FileClose ($file) Exit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 8, 2006 Moderators Share Posted April 8, 2006 This has no errors when I used Au3check... I fixed 3 things (one being I removed all the Step + 1 (proper syntax would be Step 1, but it steps 1 by default anywayexpandcollapse popup; We must include the files needed to draw a GUI. #include <GUIConstants.au3> ; Set up the variables that will hold data about a race as input by the user ; Each variable below is an array allowing data entry for up to twenty horses ; This is a temporary variable that we will use to store stuff temporarily Global $temp = "" ; This variable holds the type of race Dim $racetype[20] ; This variable holds the points we give each horse Dim $points[20] ; this variable will tell us which type of race this horse wins most often at Dim $besttype[20] ; This variable holds a yes (Y) or no (N) answer to whether the current jockey has ridden this ; horse a lot in the past Dim $regularjockey[20] ; This variable will hold a Y or N answer for whether the current jockey has regularly placed on this ; horse within the top five in races Dim $topfivejockey[20] ; This holds the amount of wins a horse has ever had in flat turf races ; so $lifetimeflatturf[5] tells us how many wins on flat turf horse five has ever had Dim $lifetimeflatturf[20] ; This holds the amount of wins a horse has ever had in jump races so that ; $lifetimejumps[4] tells us how many wins horse four has had in jump races Dim $lifetimejumps[20] ; This holds the amount of wins a horse has ever had in Aw races so that ; $lifetimeaw[7] tells us how many wins horse seven has had in Aw races Dim $lifetimeaw[20] ; This variable holds the name for each horse in the race. So $name[2] tells us the name ; of runner number two in the race. Dim $name[20] ; $age holds the age for each horse so $age[10] tells us how old horse ten is in years Dim $age[20] ; Here we get a name from the user by which they can identify the race such as "3.30 at kempton". $racename = InputBox( "Name of the race", "Please give me a name for the race and I will use this when displaying or saving results for you. Something like 3.30 AT HAYDOCK for example." ) ; now we find out how many horses are entered to run in the race $racers = InputBox( "Number of entrants in race?", "Please type in numbers how many horses are in the race" ) ; lets get the type of race $temp = InputBox( "Type of race?", "Is this race a flat race (F) , All Weather (AW) or a jump race (J)?" ) For $n = 1 To $racers $racetype[$n] = $temp Next ; Here we get the name for each horse For $n = 1 To $racers $temp = "Please type in the name of runner number " & $n & " and press ENTER on keyboard when ready to enter the name of the next runner." $name[$n] = InputBox( "What is the horses name? Please note it is easiest to enter the names in the order they are listed in your race guide.", $temp ) Next ; Now we get additional details about each runner For $n = 1 To $racers ; let us get the age of horse[$n] $temp = "What is the age of runner " & $name[$n] $age[$n] = InputBox( "Age of runner" & $n, $temp ) ; let us now get the amount of lifetime flat turf wins the horse has had $lifetimeflatturf[$n] = InputBox( "Amount of flat turf wins?", "Please enter the lifetime amount of flat turf wins for " & $name[$n] & "?" ) ; we now get the amount of lifetime jump wins for the horse $lifetimejumps[$n] = InputBox( "Amount of jump wins?", "Please enter the lifetime amount of wins for " & $name[$n] & "?" ) ; let us now get the amount of all weather wins the horse has had $lifetimeaw[$n] = InputBox( "Amount of all weather (AW) wins?", "Please enter the lifetime amount of all weather (AW) wins for " & $name[$n] & "?" ) ; find out if the current jockey has ridden this horse quite a few times ; if yes then find out if this jockey regularly gets this horse within the top five finishers $regularjockey[$n] = InputBox("Regular jockey?", "Has " & $name[$n] & "been ridden by the current jockey regularly? Look in the list of the races it has entered and decide. Type Y for YES or N if it is not a jockey used to this horse." ) If $regularjockey[$n] = "y" Then $topfivejockey[$n] = InputBox("Regularly in top five with current jockey?", "Has " & $name[$n] & " been mostly within the top five when ridden by the current jockey?" ) ElseIf $regularjockey[$n] = "n" Then $topfivejockey[$n] = "n" EndIf Next ; Now we figure out what type of race the horses are best at from AW, FLAT or JUMP and ; store this in $besttype For $n = 1 To $racers If $lifetimeaw[$n] = $lifetimeflatturf[$n] And $lifetimeaw[$n] = $lifetimejumps[$n] Then $besttype[$n] = "all rounder" If $lifetimeaw[$n] > $lifetimeflatturf[$n] And $lifetimeflatturf[$n] >= $lifetimejumps[$n] Then $besttype[$n] = "aw" If $lifetimeflatturf[$n] > $lifetimeaw[$n] And $lifetimeaw[$n] <= $lifetimejumps[$n] Then $besttype[$n] = "F" If $lifetimejumps[$n] > $lifetimeflatturf[$n] And $lifetimeflatturf[$n] >= $lifetimeaw[$n] Then $besttype = "J" Next ; Now we calculate the horses chances with the highest points meaning the best chance ; of wiining For $n = 1 To $racers ; award 3 points if the horse is best at this type of race ; or 2 if it is an allrounder If $besttype[$n] = $racetype[$n] Then $points[$n] = $points[$n] +3 If $besttype[$n] = "all rounder" Then $points[$n] = $points[$n] +2 ; award 3 points if the rider has regularly ridden the horse within the top five If $regularjockey[$n] = "y" And $topfivejockey[$n] = "y" Then $points[$n] = $points[$n] +3 Next ; now write a text file to the desktop named after the race and with these details inside $file = FileOpen("C:\race result.txt", 2) FileWriteLine( $file, "Predictive result for the race " &$name) FileWriteLine( $file, "The horse with the highest score is the probable winner" ) For $n = 1 To $racers FileWriteLine( $file, "The horse called " & $name[$n] & " scores " & $points[$n] & "points." ) Next FileClose($file) Exit Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mentalmummy Posted April 8, 2006 Author Share Posted April 8, 2006 Thanks for the quick reply! I tried the revised code and I still get the same errors. Depending on what data I enter the error changes to a different line number but is always within that for next loop I started the first post with. I just cannot figure it out, still scratching my head over it as Scite editor also reports the file has errors, just can`t figure out why. I think I`ll try a fresh look again in the morning. Thanks. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2006 Developers Share Posted April 8, 2006 AU3Check comes back with a few errors ....-and-Think the red characters are missing in this line:If $lifetimejumps[$n] > $lifetimeflatturf[$n] And $lifetimeflatturf[$n] >= $lifetimeaw[$n] Then $besttype[$n] = "J" 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 More sharing options...
mentalmummy Posted April 9, 2006 Author Share Posted April 9, 2006 AU3Check comes back with a few errors .... -and- Think the red characters are missing in this line: If $lifetimejumps[$n] > $lifetimeflatturf[$n] And $lifetimeflatturf[$n] >= $lifetimeaw[$n] Then $besttype[$n] = "J" After all those hours staring at it I feel a pratt for missing that! That seems to have sorted it out, I`m not really an idiot but how I missed that error I`ve no idea. Still, I`m glad I posted here or I may never have realised the problem without the help from here. Thanks (again) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now