Confused about storing arrays in a custom property
janschenkel at yahoo.com
Mon Aug 22 15:38:31 EDT 2011
You could 'base64Encode' the binary data before storing it, and base64decode it after retrieval from the database.
That way you don't have to worry about BINARY, and can store it in a CLOB.
Quartam Reports & PDF Library for LiveCode
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
----- Original Message -----
From: Pete <pete at mollysrevenge.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Monday, August 22, 2011 8:28 PM
Subject: Re: Confused about storing arrays in a custom property
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:
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.
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
> put "xyz" into aData["abc"]["def"]
> put "qrs" into adata["abc"]["ghi"]
> put printkeys(aData)
> you would get:
> ghi: qrs
> def: xyz
> A similar method could probably be devised to put the data back into an
> 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
> On Aug 22, 2011, at 10:29 AM, Pete wrote:
> > Thanks Andrew and Bob. Unfortunately, I'm using an sqlite database and
> > 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
> > 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
> > 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
> > into an array when I read them back from the db. So if
> > contains "xyz", the resulting line would be "abc<tab>def<tab>xyz". This
> > the cause of my other recent posts about what happens when the last item
> > 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>
> >> It sounds to me like binary is the data type you want here.
> >> --
> >> View this message in context:
> >> 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:
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode