localstorage for arrays?

can the localstorage and persiststorage be used to remember arrays? and if so, is anyone able to give me a little example on the formatting to do so?
thankyou
3,785 views 4 replies
Reply #1 Top
I thought you could just pass any data type to the local storage... Have you tried saving and reloading an array?
Reply #2 Top
From memory it just stores text, so you could loop through the array and build a text string to store with separators.

You can then read it back in, by parsing the string. It may make sense to prefix the text string with the number of items to make the loop easier to build.

e.g.
5|Red|Blue|Green|Red|Blue
Reply #3 Top
Why the number? UBound() should do the trick, shouldn't it?


Dim myVar, myArray
myVar = Object.LocalStorage("arraystring")
myArray = Split(myVar, "|")

For i = 0 to UBound(myArray)
Script.Msgbox myArray(i)
Next
Reply #4 Top
Thanks Martin and Thomassen, both are very good ideas I probably would have come up with what Martin suggested, and thankyou for the actual script example thomassen, was just wanting to make use of any already built in method for saving arrays.

Will try these out shortly cheers