localstorage for arrays?

Tuesday, April 12, 2005 by Skarny | Discussion: DesktopX

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
thomassen
Reply #1 Tuesday, April 12, 2005 8:23 AM
I thought you could just pass any data type to the local storage... Have you tried saving and reloading an array?
_Martin_
Reply #2 Wednesday, April 13, 2005 6:49 AM
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
thomassen
Reply #3 Wednesday, April 13, 2005 6:02 PM
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
Skarny
Reply #4 Saturday, April 16, 2005 12:55 AM
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

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01