Sign in to follow this  
Followers 0

Saving and reloading a 2d array to/from file

8 posts in this topic

Posted

Hey there!

I wonder what way would be the most efficient to save a 2d array of strings to a file (binary file or .txt doesn't matter to me), to easily load this array using another .au3 file.

My approach would be to save it into a text file where each textfile row represents an array row, delimited by a special character like {TAB}. Then I'd load each of these rows into the array with a FileReadLine() and some scripting.

I just wonder (after looking at StringSplit) if there might be a solution already existent in AutoIT to convert any table-like text into an array, that I just didn't find. :oops:

Does it?

Share this post


Link to post
Share on other sites



Posted

Hi, Hawk. Have you checked out _FileWriteFromArray in the help file?

Share this post


Link to post
Share on other sites

Posted

Doh, so easy, thanks!

Share this post


Link to post
Share on other sites

Posted

Hawk,

Please note, filewritefromarray handles 2D arrays. It's "sister" function, filereadtoarray does not.

kylomas

Share this post


Link to post
Share on other sites

Posted (edited)

A quick search and you'll find plenty of examples to create multi-dimensional arrays (normally 2d) from reading a file.

Source: there is also one floating around by UEZ but I can never find it!

Edited by guinness

Share this post


Link to post
Share on other sites

Posted

Try this: StringSplitW()

Br,

UEZ

Share this post


Link to post
Share on other sites

Posted

Thanks UEZ, I'll keep a mental note of that.

Share this post


Link to post
Share on other sites

Posted

A quick search and you'll find plenty of examples to create multi-dimensional arrays (normally 2d) from reading a file.

Source: there is also one floating around by UEZ but I can never find it!

Damn that thing is pretty slow, but it works, thanks!

Luckily I only have an array[800][5]. It takes like 2 seconds for these 4000 entries.

But I am sooo lazy :oops: and it's so simple to use only _FileWriteFromArray2D and _FileReadToArray2D.

As long as I don't use bigger arrays, I will stick with it.

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