Confused about storing arrays in a custom property

Pete pete at mollysrevenge.com
Mon Aug 22 14:28:17 EDT 2011


I do store it in a cprop for use during a single run but I have to preserve
the value between runs so want to store it in an external file. I know there
are ways to do that using separate stacks within standalones - I just prefer
to use an external file rather than that method, especially if I already
have one open for other purposes.

Trevors' printKeys doesn't quite do the job unfortunately.  It doesn't print
all the keys on each line, just indents depending on the key level.  In my
case, I need the output for your example to be:

abc<tab>def<tab>xyz
abc<tab>ghi<tab>qrs

I could probably have used PrintKeys and dealt with the indented format when
recreating the array but it was fun coming up with the algorithm to produce
the above output, plus it made the reassembly of the array very easy.

Haven't had a chance to experiment with simulating a BINARY column in sqlite
yet but if I find a way to do it, I'll probably go with that method.


Pete
Molly's Revenge <http://www.mollysrevenge.com>




On Mon, Aug 22, 2011 at 10:51 AM, Bob Sneidar <bobs at twft.com> wrote:

> interesting. Trevor shared some time ago his printKeys() function so that
> given:
>    put "xyz" into aData["abc"]["def"]
>    put "qrs" into adata["abc"]["ghi"]
>    put printkeys(aData)
>
> you would get:
> abc
>     ghi: qrs
>     def: xyz
>
> A similar method could probably be devised to put the data back into an
> array.
>
> All this seems like a lot of trouble though. Why not just store the array
> in a custom property?
> set the aArray of this card to aData -- or this stack if it is a single
> array
>
> Bob
>
>
> On Aug 22, 2011, at 10:29 AM, Pete wrote:
>
> > Thanks Andrew and Bob.  Unfortunately, I'm using an sqlite database and
> as
> > far as I can tell from the docs, it doesn't have a binary data type.  I
> > could define a column as BINARY but it would end up as NUMERIC in
> sqlite's
> > world.  I'll give it a whirl though.
> >
> > I've actually now written a function to convert a multidimensional array
> > into a string with one line for each of the first level keys and each
> line
> > containing the keys separated by tabs, ending up with the value in the
> > lowest level key.  That way I can just store the text string in the db
> > without a problem, and I also have a simple command to assemble the
> strings
> > into an array when I read them back from the db. So if
> Array["abc"]["def"]
> > contains "xyz", the resulting line would be "abc<tab>def<tab>xyz".  This
> was
> > the cause of my other recent posts about what happens when the last item
> in
> > a string is empty.  Provided some interesting recursion opportunities!
> >
> > Pete
> > Molly's Revenge <http://www.mollysrevenge.com>
> >
> >
> >
> >
> > On Mon, Aug 22, 2011 at 9:49 AM, Andrew Kluthe <andrew at rjdfarm.com>
> wrote:
> >
> >> It sounds to me like binary is the data type you want here.
> >>
> >> --
> >> View this message in context:
> >>
> http://runtime-revolution.278305.n4.nabble.com/Confused-about-storing-arrays-in-a-custom-property-tp3757539p3760664.html
> >> Sent from the Revolution - User mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> use-livecode mailing list
> >> use-livecode at lists.runrev.com
> >> Please visit this url to subscribe, unsubscribe and manage your
> >> subscription preferences:
> >> http://lists.runrev.com/mailman/listinfo/use-livecode
> >>
> >>
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>



More information about the use-livecode mailing list