Data Persistence

John McKenzie davros at bellaliant.net
Wed Aug 15 17:57:37 EDT 2018



 Hello again, everyone.

 Jacqueline, I enjoyed the fact you shared your story of not
conforming to gender stereotypes with your childhood interests. Find it
sad that science and engineering in general was (is?) considered a boys
thing.

 Feel like I want to inject my two cents worth about software licences
but it is a topic that could derail the list and I know I should not
contribute to that. Know I was OK with and understood the off the cuff
nature of "silly" and definitely do not agree with everything licences
force upon us in modern times.


  So I continue to ask questions to help with my data persistence
problem on Android.

 While I want to make sure my syntax is correct I firstly need to know
if conceptually what I am doing will work/is correct.

 On my three cards (each records numbers for a different flight) the
fields now all save their info to an array, flightArr[], upon
closeField as suggested by the crowd here on the mailing list.

 I have it set-up so that when I stitch to another app (a phone call
comes in, or I need to look up an airport code using an app, etc) it
saves the info from each field on every card to a text file and upon
opening it repopulates those text fields. This is accomplished using
the handlers on shutdown and on openStack. The change I am going to try
unless told not to in reply to this message is to encode the array into
something and deencode it upon openStack.

 So each field would have put something into the array upon closeField.

 Would it work that upon on shutdown I could just say encode the array
and then upon openStack I deencode the array and have the commands to
populate the appropriate fields with their values from the array that
was just deencoded?

 My array is called flightArr[]. Want to check with all of you that the
syntax I was going to try is correct, although I suppose it does not
matter if conceptually this is a bad idea. This would be on the stack.

on shutdown
   set the defaultFolder to specialFolderPath("cache")
   put arrayEncode(flightArr) into theEncodedArray
   put theEncodedArray into URL ("binfile:" & theflightArray)
   pass shutdown
end shutdown

on openstack
   set the defaultFolder to specialFolderPath("cache")
   put URL ("binfile:" & theflightArray) into theEncodedArray
   put arrayDecode(theEncodedArray) into flightArr
   put flightArr[1] into field flight of card 1
   put flightArr[2] into field sta of card 1
   put flightArr[3] into field ata of card 1
# Etc, etc, for each text field for each card
end openstack

 I see a few things already that make me think it is unlikely to be
that simple. Also the array probably needs a "[]" after it every time.
So it is probably embarrassingly wrong and I should spend a little more
time reading the dictionary before sending this off but I have to leave
for work in a few minutes.

Thanks for your help.




More information about the use-livecode mailing list