Saving multi-dimensional array to file? lazarus / 61-Beginners ---------------------------------------------------------------------- Trenatos · 2015-08-13 18:51 I've gotten to the point where most of the functionality of the first part of the software is done, the last thing is being able to load/save data. What's a simple way of saving a multi-dimensional array of strings to file, and read that file into an array again? ---------------------------------------------------------------------- derek.john.evans · 2015-08-13 18:53 What do you mean by multi-dimensional array of strings? ---------------------------------------------------------------------- eny · 2015-08-13 18:55 array[1..10, 1..10, 1..10] of string.... ---------------------------------------------------------------------- Trenatos · 2015-08-13 18:57 servers: array[1..100] of array[1..8] of string; ---------------------------------------------------------------------- derek.john.evans · 2015-08-13 18:57 Are the arrays dynamic? or static in size ---------------------------------------------------------------------- Trenatos · 2015-08-13 19:01 Dynamic, but I can go static if that's easier. ---------------------------------------------------------------------- derek.john.evans · 2015-08-13 19:04 Geez, funny how such a simple problem yields so many possibilities. Eek! To tell you the truth. The answers are going to be all over the place. ---------------------------------------------------------------------- taazz · 2015-08-13 19:07 there is no magic bullet that can help you save everything with one command if that is what you are after. Think of a string as a pointer to a dynamic array of chars. You need to use loops and access each string individually to save it.Change the strings to shortstring and things might become easier but not by much. ---------------------------------------------------------------------- eny · 2015-08-13 19:11 Since this is the Beginners section, this might give you some ideas: http://wiki.lazarus.freepascal.org/File_Handling_In_Pascal ---------------------------------------------------------------------- Trenatos · 2015-08-13 19:19 Not really looking for "magic bullet" solutions, just solutions. I'm definitely a Pascal beginner, and this is the beginner section. A trick we use in the CFML world is to serialize complex structures into JSON strings, which can be loaded and saved as any string data, and then deserialized into complex structures again. ---------------------------------------------------------------------- User137 · 2015-08-13 19:26 1 way is to first write the array size numbers in file, and then each string. When loading, read the size numbers, allocate the whole array and read strings. ---------------------------------------------------------------------- Trenatos · 2015-08-13 20:19 I went simple and straight forward, nested loops and linewrites/reads, works like a charm but not horribly sturdy if someone tries to modify the file by hand (Which they never should anyway). With that working, part 1 of this project is done  Some serious thank-yous to all of you. When finished, this project will go up open source on GitHub