Hello, I have a little question about arrays on which I am quite stuck on.
I have an array.
#("BoxA", "BoxB")
I manage to save this array in an external file, a txt file. My array in here will then look like this :
BoxA,BoxB,
Here now my issue. I want to reload this array back into my script, but for now I only succed to reload 1 of the component of my array !.
I am unable to find back my #("BoxA", "BoxB") from the BoxA,BoxB, saved in the file ! I have try so many diferent tricks that I cant tell them all in here...
Someone could at least point to the good direction ?
Thanks !
Replies
have another look through the textstream/parsing stuff in the reference - there'll be something you can use
this should do the trick. I suggest to make a function out of it.
( -- Open the FileStream to read from disc local theFileStream = openFile "C:/test.txt" -- Initialize an empty Array to store the result local asWords = #() -- Enter a while loop that terminates once the full file has been read while ((eof theFileStream) == false) do ( -- Read one set of characters delimited by a comma... local sWord = readDelimitedString theFileStream "," -- ...And append it to the result array append asWords sWord ) -- Close the FileStream close theFileStream -- Cleanup memory used by the FileStream free theFileStream -- Display the resulting Array in the Listener format "asWords: %\n" asWords )Cheers
Looks like I was completly wrong in my way to loop in the file.
Thanks ! : )
McGreed : those ini files looks very interesting indeed, thanks for the information ! :]
a = filterString "bibot¦Tiktika¦string1¦23¦true"
print a[3] -- gives "string1"