Jump to content

Easiest way to load preset file and put in array?


 Share

Recommended Posts

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.

Link to comment
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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...