Ward Gerlach Posted January 6, 2009 Posted January 6, 2009 When I try running the code below I get an AutoIt Error dialog box: "Error: Expected a "=" in assignment statement." CODEDim $Val $File = FileOpen ("C:\Scripts\Data\List.txt", 0) If $File = -1 Then MsgBox (64, "Error", "File Open Failed") Exit EndIf For $I = 1 to 99 $Val ($I) = FileReadLine ("C:\Scripts\Data\List.txt") If @error = -1 Then ExitLoop Next It would seem that filling an array from a text file is a pretty basic thing. So either I'm missing something real basic, or filling AutoIt arrays from a file is not as simple as it should be. Any pointers would be appreciated.... Ò¿Öautoiterror.bmp
Valuater Posted January 6, 2009 Posted January 6, 2009 Man, am slow this morning...Dim $Val[100] $File = FileOpen("C:\Scripts\Data\List.txt", 0) If $File = -1 Then MsgBox(64, "Error", "File Open Failed") Exit EndIf For $I = 1 To 99 $Val[$I] = FileReadLine("C:\Scripts\Data\List.txt") If @error = -1 Then ExitLoop Next8)
Ward Gerlach Posted January 7, 2009 Author Posted January 7, 2009 Anybody got an idea? Or am I just dense/slow?
picaxe Posted January 7, 2009 Posted January 7, 2009 Have you tried Valuaters fix?. You can also use _FileReadToArray, see help file example.
Ward Gerlach Posted January 7, 2009 Author Posted January 7, 2009 Picaxe, Valuater's reply was just a tidyup of my code, except for the Dim (100) - which I'd already tried, but got the same error msg. I also tried not using Dim at all, with the same results. My apologies for not being complete with what I'd already tried. I'm just getting frustrated at having such a simple thing kick my behind all around the block! As for _FileReadToArray - Thanks! I'll try that right now.
Ward Gerlach Posted January 7, 2009 Author Posted January 7, 2009 Picaxe, the _FileReadToArray works like a champ! Thank You! I still feel like a dummy for not digging into the UDFs like I should have. Anyone think that I should submit the original issue as a bug? Given the non-assistance provided by the error message?
picaxe Posted January 7, 2009 Posted January 7, 2009 Did you notice the [] brackets which is the correct array syntax, in Valauters fix instead of the () brackets in your code.
Ward Gerlach Posted January 7, 2009 Author Posted January 7, 2009 Sweet suffering catfish! That is two real big "My Bad" - Plus smacking self in forehead. Repeat as required. I *know* about [] vs (). Sheesh....
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