How to read a multi-dimensional array from a text file?
Posted: Sun Feb 06, 2022 4:35 pm
Hi,
There are lots of functions that do this, already written. But the arrays aren't defined with an array syntax, inside the file.
Let's say you have a text file with
or an assignment like
(where we have MainArray_a declared as PUBLIC inside the calling routine).
How can we read this array from a text .txt file, and populate it in an array variable inside the program?
There are lots of functions that do this, already written. But the arrays aren't defined with an array syntax, inside the file.
Let's say you have a text file with
Code: Select all
{ ;
{"First","First Item", ;
{{"First SubItem", "First SubItem from First", {||qout("First SubItem from First")}},;
{"Second SubItem", "Second SubItem from First", {||qout("Second SubItem from First")}},;
{"Third SubItem", "Third SubItem from First", {||qout("Third SubItem from First")}} } ;
}, ;
{"Second","Second Item", ;
{{"First SubItem", "First SubItem from Second", {||qout("First SubItem from Second")}},;
{"Second SubItem", "Second SubItem from Second", {||qout("Second SubItem from Second")}},;
{"Third SubItem", "Third SubItem from Second", {||qout("Third SubItem from Second")}} } ;
}, ;
{"Third","Third SubItem",0}, ;
{"Fourth","Fourth SubItem",{||qout("Fourth SubItem")} } ;
}
Code: Select all
MainArray_a := { ;
{"First","First Item", ;
{{"First SubItem", "First SubItem from First", {||qout("First SubItem from First")}},;
{"Second SubItem", "Second SubItem from First", {||qout("Second SubItem from First")}},;
{"Third SubItem", "Third SubItem from First", {||qout("Third SubItem from First")}} } ;
}, ;
{"Second","Second Item", ;
{{"First SubItem", "First SubItem from Second", {||qout("First SubItem from Second")}},;
{"Second SubItem", "Second SubItem from Second", {||qout("Second SubItem from Second")}},;
{"Third SubItem", "Third SubItem from Second", {||qout("Third SubItem from Second")}} } ;
}, ;
{"Third","Third SubItem",0}, ;
{"Fourth","Fourth SubItem",{||qout("Fourth SubItem")} } ;
}
How can we read this array from a text .txt file, and populate it in an array variable inside the program?