Jump to content
Sign in to follow this  
Ward Gerlach

Problem Filling Array From a Text File

Recommended Posts

Ward Gerlach

When I try running the code below I get an AutoIt Error dialog box: "Error: Expected a "=" in assignment statement."

CODE
Dim $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

Share this post


Link to post
Share on other sites
Ward Gerlach

Anybody got an idea? Or am I just dense/slow?

Share this post


Link to post
Share on other sites
picaxe

Have you tried Valuaters fix?. You can also use _FileReadToArray, see help file example.

Share this post


Link to post
Share on other sites
Ward Gerlach

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.

Share this post


Link to post
Share on other sites
Ward Gerlach

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?

Share this post


Link to post
Share on other sites
picaxe

Did you notice the [] brackets which is the correct array syntax, in Valauters fix instead of the () brackets in your code.

Share this post


Link to post
Share on other sites
Ward Gerlach

Sweet suffering catfish!

That is two real big "My Bad" - Plus smacking self in forehead.

Repeat as required.

I *know* about [] vs ().

Sheesh....

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  

×