Sign in to follow this  
Followers 0
sensalim

Easiest way to load preset file and put in array?

8 posts in this topic

Say I have file which format is like this:

########;Description\n

Example:

100;Item 1

101;Item 2

102;Item 3

etc

What is the easiest way to load this file, say "test.dat" into an array in my test.au3 file?

I know you'd need a global array, use fileopen, filereadline etc and fileclose... but is there

any easier way?

Thanks.

Share this post


Link to post
Share on other sites



#include <array.au3>
#include <file.au3>

Dim $tempArray

_FileReadToArray("file.txt", $tempArray)

_ArrayDisplay($tempArray)

Dim $myArray[$tempArray[0] + 1][2]

$myArray[0][0] = $tempArray[0]
For $X = 1 to $tempArray[0]
    $temp = StringSplit($tempArray[$X], ";")
    $myArray[$X][0] = $temp[1]
    $myArray[$X][1] = $temp[2]
Next

_ArrayDisplay($myArray)

Share this post


Link to post
Share on other sites

What the, how come when I search on help file for filereadtoarray or _filereadtoarray, it came out nothing?

Share this post


Link to post
Share on other sites

That is also my version.

Can you search for that, mine says "No topics found."

This sucks.

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