Data Persistence

classic Classic list List threaded Threaded
43 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Data Persistence

Trevor DeVore via use-livecode


 Hello, all.

 I am new to Livecode development but not computing. When I heard of
something that was inspired by Hypercard I had to know more. Used
Livecode to make a little app on my phone for work but the level of
interest this app generated now make me want to finish it, and maybe
even share and/or sell it. Livecode is pretty cool and I am looking
forward to learning how to use it and do stuff with it.

 So my first (and I sadly suspect not last) question to the list is
about persistence on the Android platform.

 My job is in the aviation industry. For now I want to get it working.
Then I will polish it off, beta test it, etc. One airline rep gave me
his card and said to call him about it if I wanted to sell it.

 The get it working part is where I need your help. I was unclear on
what Livecode could and could not do so I emailed them and a very
helpful person named Heather educated me a bit. Now that I know it
might work for my application I would appreciate your help in getting
it working.

 Right now it will be an Android app. iOS app later probably.

 The app is to help me record times and other facts about plane
landings (like when the plane landed and how much fuel is requested by
the Captain). At the end of a flight I can press a button and an email
addressed to our operations centre is auto-populated in the body of the
text with these numbers. For example if I press the button labelled
"ATA" (actual time of arrival) it places the current time in the text
field next to the ATA button. I can touch the text field and edit the
time if need be.

 What I need help with is the issue of persistence. If I get an SMS
message, a phone call or an alarm goes off the data will be wiped out
when I return to the app. Sometimes if I leave the app to check
something else and come back the data is there and other times the text
fields are all blank. Tried saving the data in a text file and having
the app load it up each time it starts. Most of the time this does not
work. Usually when I start the app up again at the beginning of the
next shift it starts up with the times of yesterday's flight.


 So I would like to know how to properly hold the data so the entries
in the text fields are still there when I go to another app then come
back to mine. looking to have basic persistence in my app.

 Guidance on the (or one of the) proper way(s) to accomplish this
would be most appreciated.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
I built a time tracking app that had the same type of persistence requirement. I used a text file for the data store. Each time any field had a change, the data was saved again. When loading the app it would import the current data. Data was only cleared on request (and I would only allow that after it was emailed). When cleared, I deleted the file.

As you have discovered, on mobile your app can be terminated at any time and you may not be given a chance to save data before then.

My test was on iOS but it should work the same on Android.

Thanks,
Brian
On Jul 23, 2018, 4:58 PM -0500, John McKenzie via use-livecode <[hidden email]>, wrote:

>
>
> Hello, all.
>
> I am new to Livecode development but not computing. When I heard of
> something that was inspired by Hypercard I had to know more. Used
> Livecode to make a little app on my phone for work but the level of
> interest this app generated now make me want to finish it, and maybe
> even share and/or sell it. Livecode is pretty cool and I am looking
> forward to learning how to use it and do stuff with it.
>
> So my first (and I sadly suspect not last) question to the list is
> about persistence on the Android platform.
>
> My job is in the aviation industry. For now I want to get it working.
> Then I will polish it off, beta test it, etc. One airline rep gave me
> his card and said to call him about it if I wanted to sell it.
>
> The get it working part is where I need your help. I was unclear on
> what Livecode could and could not do so I emailed them and a very
> helpful person named Heather educated me a bit. Now that I know it
> might work for my application I would appreciate your help in getting
> it working.
>
> Right now it will be an Android app. iOS app later probably.
>
> The app is to help me record times and other facts about plane
> landings (like when the plane landed and how much fuel is requested by
> the Captain). At the end of a flight I can press a button and an email
> addressed to our operations centre is auto-populated in the body of the
> text with these numbers. For example if I press the button labelled
> "ATA" (actual time of arrival) it places the current time in the text
> field next to the ATA button. I can touch the text field and edit the
> time if need be.
>
> What I need help with is the issue of persistence. If I get an SMS
> message, a phone call or an alarm goes off the data will be wiped out
> when I return to the app. Sometimes if I leave the app to check
> something else and come back the data is there and other times the text
> fields are all blank. Tried saving the data in a text file and having
> the app load it up each time it starts. Most of the time this does not
> work. Usually when I start the app up again at the beginning of the
> next shift it starts up with the times of yesterday's flight.
>
>
> So I would like to know how to properly hold the data so the entries
> in the text fields are still there when I go to another app then come
> back to mine. looking to have basic persistence in my app.
>
> Guidance on the (or one of the) proper way(s) to accomplish this
> would be most appreciated.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
welcome john.....just as a tip....arrayencode is very handy for saving
whatever you need....you can always also use a sqlite database to store
data and load / refresh whenever you need....it also also works as
in-memory database.

On Mon, Jul 23, 2018 at 6:21 PM, Brian Milby via use-livecode <
[hidden email]> wrote:

> I built a time tracking app that had the same type of persistence
> requirement. I used a text file for the data store. Each time any field had
> a change, the data was saved again. When loading the app it would import
> the current data. Data was only cleared on request (and I would only allow
> that after it was emailed). When cleared, I deleted the file.
>
> As you have discovered, on mobile your app can be terminated at any time
> and you may not be given a chance to save data before then.
>
> My test was on iOS but it should work the same on Android.
>
> Thanks,
> Brian
> On Jul 23, 2018, 4:58 PM -0500, John McKenzie via use-livecode <
> [hidden email]>, wrote:
> >
> >
> > Hello, all.
> >
> > I am new to Livecode development but not computing. When I heard of
> > something that was inspired by Hypercard I had to know more. Used
> > Livecode to make a little app on my phone for work but the level of
> > interest this app generated now make me want to finish it, and maybe
> > even share and/or sell it. Livecode is pretty cool and I am looking
> > forward to learning how to use it and do stuff with it.
> >
> > So my first (and I sadly suspect not last) question to the list is
> > about persistence on the Android platform.
> >
> > My job is in the aviation industry. For now I want to get it working.
> > Then I will polish it off, beta test it, etc. One airline rep gave me
> > his card and said to call him about it if I wanted to sell it.
> >
> > The get it working part is where I need your help. I was unclear on
> > what Livecode could and could not do so I emailed them and a very
> > helpful person named Heather educated me a bit. Now that I know it
> > might work for my application I would appreciate your help in getting
> > it working.
> >
> > Right now it will be an Android app. iOS app later probably.
> >
> > The app is to help me record times and other facts about plane
> > landings (like when the plane landed and how much fuel is requested by
> > the Captain). At the end of a flight I can press a button and an email
> > addressed to our operations centre is auto-populated in the body of the
> > text with these numbers. For example if I press the button labelled
> > "ATA" (actual time of arrival) it places the current time in the text
> > field next to the ATA button. I can touch the text field and edit the
> > time if need be.
> >
> > What I need help with is the issue of persistence. If I get an SMS
> > message, a phone call or an alarm goes off the data will be wiped out
> > when I return to the app. Sometimes if I leave the app to check
> > something else and come back the data is there and other times the text
> > fields are all blank. Tried saving the data in a text file and having
> > the app load it up each time it starts. Most of the time this does not
> > work. Usually when I start the app up again at the beginning of the
> > next shift it starts up with the times of yesterday's flight.
> >
> >
> > So I would like to know how to properly hold the data so the entries
> > in the text fields are still there when I go to another app then come
> > back to mine. looking to have basic persistence in my app.
> >
> > Guidance on the (or one of the) proper way(s) to accomplish this
> > would be most appreciated.
> >
> >
> > _______________________________________________
> > use-livecode mailing list
> > [hidden email]
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode

 Tom, thank you for welcoming me. Much different than some online
programming groups. :-)


 Brian and Tom thank you for your replies about my Android data
persistence problem. An SQLite database seems like extreme overkill but
I will give it a try if it is needed to get the app to work. Does this
require me to pre-install any sort of database software?

 Brian, I gathered from your post that the only way to work with a text
file as data storage on Android is to save every time a field is
changed? How would I do this in such a way that it knows to save when
"1421" is typed as a time of day as opposed to the app trying to save
it after "1" is typed, then again when "2" is typed, etc. Or perhaps
there is no way and I have to re-save every time a character it typed.


  I am super duper busy this week, especially this weekend. Will really
get back to the problem in earnest next week.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
Hi John,

> Am 27.07.2018 um 19:47 schrieb John McKenzie via use-livecode <[hidden email]>:
>
> Tom, thank you for welcoming me. Much different than some online
> programming groups. :-)
>
> Brian and Tom thank you for your replies about my Android data
> persistence problem. An SQLite database seems like extreme overkill but
> I will give it a try if it is needed to get the app to work. Does this
> require me to pre-install any sort of database software?

nope, unlike batteries, everything is included in LC! :-)

> Brian, I gathered from your post that the only way to work with a text
> file as data storage on Android is to save every time a field is
> changed? How would I do this in such a way that it knows to save when
> "1421" is typed as a time of day as opposed to the app trying to save
> it after "1" is typed, then again when "2" is typed, etc. Or perhaps
> there is no way and I have to re-save every time a character it typed.

Save "on closefield", means when the user has finished typing and "leaves" the field.

>  I am super duper busy this week, especially this weekend. Will really
> get back to the problem in earnest next week.

Whatever... :-)


Best

Klaus

--
Klaus Major
http://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
John McKenzie wrote:

 > An SQLite database seems like extreme overkill but I will give it
 > a try if it is needed to get the app to work.

SQLite is very feature-rich, but if you don't need the relationality
provided by a full-featured RDBMS it can be like swatting flies with a
grenade launcher.

Persistence can be provided by any format that can be written to disk.
You may be surprised by how many programs use simple flat text files.
And in LC, arrays are easy and efficient to work with, and can be
serialized to disk with arrayEncode (resulting in files I affectionately
call "LSON", a LiveCode-optimized alternative to the
JavaScript-optimized JSON).

Indeed, many who use an RDBMS write code to return the result of queries
in the form of an LC array.  If you don't need the relationality, and if
your data is of a size that fits comfortably in RAM, using an array
directly is about as simple as it can be.

If your data does not fit comfortably in RAM, you may find that breaking
it into multiple LSON files can work quite nicely.


 > Does this require me to pre-install any sort of database software?

Selecting the SQLite driver in the Standalone Build should be all that's
needed.


 >  Brian, I gathered from your post that the only way to work with a
 > text file as data storage on Android is to save every time a field
 > is changed? How would I do this in such a way that it knows to save
 > when "1421" is typed as a time of day as opposed to the app trying
 > to save it after "1" is typed, then again when "2" is typed, etc.
 > Or perhaps there is no way and I have to re-save every time a
 > character it typed.

Finding appropriate auto-save triggers is the third hard thing in
computing (the first two being cache invalidation and naming things <g>).

Saving on every keystroke may be overkill. Saving on closeField may
suffice when the contents of each field do not contain much data.  If
you have a long field in which a user may spend significant time, you
may consider a periodic timer for saving as a middle path between
closeField and textChanged.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Welcome John!

You will need this, I would endorse Tom's arrayEncode.  

If you have not: Learn to array code RIGHT NOW, before going further with Livecode. I resisted array for years, and it bought me a boat load of silly coding of text files. And 100 of lines of unnecessary code.... then I  are learned about arrays. I broke my head of the desk.. saying "oh wow is me!.... I have could have saved thousand of hours and lines of codes if use arrays from the beginning!" (ha)

  (rough draft code)


Local sTempParamArray # may good to save a local,

Command saveTempParams

                Put fld "fuelNeed" into  pTempParamArray["fuelNeeded'}
                Put fld "timeToArrival" into  pTempParamArray["timeToArrival""
                # etc.
                Put pTempParamArray into sTempParamArray
                storeTempParams pTempParamArray

End saveTempParams

command storeTempParams pTempParamArray

        put   specialFolderPath("documents") & "/tempSavedParams" into  tSavedPath
        put sTempParamArray into url ("binfile:" & tSavedPath)

end storeTempParams

# you will have some trigger get them back, I don't know what that would be:

Function getTempSavedParams

        Put   specialFolderPath("documents") & "/tempSavedParams" into  tSavedPath
        put url ("binfile:" & tSavedPath) into pTempParamArray
        put pTempParamArray into sTempParamArray
        return pTempParamArray

end getTempSavedParams

command reLoadSettings

  put getTempSavesParams() into pLastParams
        put pLastParams["fuelNeeded"] into # whatever
        put pLastParams["timeToArrival"] into # whatever
        # etc.

End reLoadSettings

# code is a little verbose but easy to debug later.
# other wizards can improve on my baby xTalk
 
BR

On 7/23/18, 11:57 AM, "use-livecode on behalf of John McKenzie via use-livecode" <[hidden email] on behalf of [hidden email]> wrote:

    What I need help with is the issue of persistence.

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode

 Thanks for the extra comments everyone. Glad my thought process was
correct, databse is overkill, saving every text change is too much,
etc, etc.

 As I said I will not be able to really do anything until next week.

 Thanks for mentioning the closeField command guys. I will check it
out, but the name sounds like it explains it, loose focus on the field,
field is closed, handling activated.

 Because I like word play I might make my own text file format, the
"Extended Livecode Optimized Serialized Object Notation" format or
ELSON. It adds just enough features to LSON to make identical to JSON.
Being stupid and redundant it will be the hot new buzzword in the
computing industry.


 Using arrays intigues me, especially if I can just keep it in RAM (It
is a small amount of data for sure).

 Thanks for your continued help everyone. Off to super busy weekend
planning and working on an event for Sunday. Will update you/ask
follow-ups next week.




_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
John McKenzie wrote:
 >  Because I like word play I might make my own text file format, the
 > "Extended Livecode Optimized Serialized Object Notation" format or
 > ELSON. It adds just enough features to LSON to make identical to JSON.
 > Being stupid and redundant it will be the hot new buzzword in the
 > computing industry.

Buzzwords are important.  If you don't use enough of them you'll never
find adequate funding. :)


 >  Using arrays intigues me, especially if I can just keep it in RAM (It
 > is a small amount of data for sure).

One great thing about LC's built-in support for arrays is that it's
built-in.

JSON has become used in so many other languages that we've forgotten why
it was invented:  to serialize JavaScript objects as simply and
efficiently as possible using features already built into the JavaScript
interpreter.

LSON is that for us, as much a with-the-grain approach to data handling
in LiveCode as JSON is for JavaScript.

ELSON and any number of other variants can be fun, but what will you do
with the deserialized native form as you work with it in your program?
If that native form is an array, there may be no need to do anything
more than what LC already gives us straight out of the box.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Sannyasin Brahmanathaswami wrote:

 >   (rough draft code)
 >
 > Local sTempParamArray # may good to save a local,
 >
 > Command saveTempParams
 >
 > Put fld "fuelNeed" into  pTempParamArray["fuelNeeded'}
 > Put fld "timeToArrival" into  pTempParamArray["timeToArrival""
 > # etc.
 > Put pTempParamArray into sTempParamArray
 > storeTempParams pTempParamArray
 >
 > End saveTempParams
 >
 > command storeTempParams pTempParamArray
 >
 > put   specialFolderPath("documents") & "/tempSavedParams" into
tSavedPath
 > put sTempParamArray into url ("binfile:" & tSavedPath)
 >
 > end storeTempParams

A good outline, but missing a key step:  arrays are collections of
pointers and in their native form are not a contiguous bytestream, so
attempting to write one to disk directly with yield an empty file.

This is where serialization comes in, collecting all the disparate
pointer contents and packing them into a bytestream that can be saved or
transported, using arrayEncode:

command storeTempParams pTempParamArray
   put specialFolderPath("documents") & "/tempSavedParams" into \
      tSavedPath
   put arrayEncode(sTempParamArray) into url ("binfile:" & tSavedPath)
end storeTempParams


And because arrayDecode will throw a fatal error if you attempt to use
it with anything other than actual LSON data, we can't just check "the
result" afterward; better to wrap it in a try/catch:

Function getTempSavedParams
   Put specialFolderPath("documents") & "/tempSavedParams" into \
      tSavedPath
   put url ("binfile:" & tSavedPath) into pTempParamArray
   -- Always check I/O for errors:
   if the result is empty then
      return "Error in getTempSavedParams: "& the result for error
    end if
    -- Try as LSON:
    try
      put arrayDecode(pTempParamArray) into pTempParamArray
    catch tErr
      return "Not a valid array file: "& tSavedPath for error
    end try
    --
    return pTempParamArray
end getTempSavedParams


--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
On 27/07/2018 20:17, Richard Gaskin via use-livecode wrote:

>
> >  Using arrays intigues me, especially if I can just keep it in RAM (It
> > is a small amount of data for sure).
>
> One great thing about LC's built-in support for arrays is that it's
> built-in.
>
> JSON has become used in so many other languages that we've forgotten
> why it was invented:  to serialize JavaScript objects as simply and
> efficiently as possible using features already built into the
> JavaScript interpreter.
>
> LSON is that for us, as much a with-the-grain approach to data
> handling in LiveCode as JSON is for JavaScript.
I just wish there was a human-readable, human-editable-in-a-text-editor
variant of LSON :-)

Someday, when I have some spare time, ...

-- Alex.



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Richard Gaskin
    This is where serialization comes in, collecting all the disparate
    pointer contents and packing them into a bytestream that can be saved or
    transported, using arrayEncode:

Ha! I knew that would bring out something useful... thanks for upgrading the handlers.

Richard wrote " If that native form is an array, there may be no need to do anything
more than what LC already gives us straight out of the box."

I have been toying with this for some time, but like Alex said..

"I just wish there was a human-readable, human-editable-in-a-text-editor
variant of LSON :-)"

Keeps me in JSON

BR


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
On 7/27/18 12:47 PM, John McKenzie via use-livecode wrote:
>   Tom, thank you for welcoming me. Much different than some online
> programming groups. :-)

We love new users, it's more brains for the collective. :)

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
Your Braiiiinssss. will be assimilated. (borg zombies FTW)

On Fri, Jul 27, 2018 at 3:39 PM J. Landman Gay via use-livecode <
[hidden email]> wrote:

> On 7/27/18 12:47 PM, John McKenzie via use-livecode wrote:
> >   Tom, thank you for welcoming me. Much different than some online
> > programming groups. :-)
>
> We love new users, it's more brains for the collective. :)
>
> --
> Jacqueline Landman Gay         |     [hidden email]
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
I tried reading an "LSON" format, but it's not straight forward. It's easier to simply arrayDecode the LSON and work with the array. And since you can convert the array to a memory sqLite database and back again with my handy dandy handlers, everybody wins!

Bob S


> On Jul 27, 2018, at 12:52 , Alex Tweedly via use-livecode <[hidden email]> wrote:
>
> On 27/07/2018 20:17, Richard Gaskin via use-livecode wrote:
>
>>
>> >  Using arrays intigues me, especially if I can just keep it in RAM (It
>> > is a small amount of data for sure).
>>
>> One great thing about LC's built-in support for arrays is that it's built-in.
>>
>> JSON has become used in so many other languages that we've forgotten why it was invented:  to serialize JavaScript objects as simply and efficiently as possible using features already built into the JavaScript interpreter.
>>
>> LSON is that for us, as much a with-the-grain approach to data handling in LiveCode as JSON is for JavaScript.
> I just wish there was a human-readable, human-editable-in-a-text-editor variant of LSON :-)
>
> Someday, when I have some spare time, ...
>
> -- Alex.


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
On 7/27/18 2:26 PM, Richard Gaskin via use-livecode wrote:
> if the result is empty then
>    return "Error in getTempSavedParams: "& the result for error
> end if

I believe you had a thinko: "not empty", yes?

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
On the subject of sqLite/memory databases and preferences/data persistence,
rather than using an array, and doing the encode/decode stuff, would it
make sense to do the following..
1. open an empty in memory database
2. attach a disk based database
3. copy the required table(s) from disk base to memory base

At this point, for data reads you have a super fast sqlite in memory
database.  For updates, do a double update, both in memory, and disk.

It seems like this would be more efficient than re-encoding an array every
time there is an update and writing the whole thing out to disk each time,
rather than updating just whatever small change might need to be made to
sqlite.

The affects and requirements would be similar. Update the array, (1 update)
ecode and write to disk (second update)  vs update in mem sqlite, and
update attached sqlite database.

Does my thinking make sense?

On Fri, Jul 27, 2018 at 4:11 PM Bob Sneidar via use-livecode <
[hidden email]> wrote:

> I tried reading an "LSON" format, but it's not straight forward. It's
> easier to simply arrayDecode the LSON and work with the array. And since
> you can convert the array to a memory sqLite database and back again with
> my handy dandy handlers, everybody wins!
>
> Bob S
>
>
> > On Jul 27, 2018, at 12:52 , Alex Tweedly via use-livecode <
> [hidden email]> wrote:
> >
> > On 27/07/2018 20:17, Richard Gaskin via use-livecode wrote:
> >
> >>
> >> >  Using arrays intigues me, especially if I can just keep it in RAM (It
> >> > is a small amount of data for sure).
> >>
> >> One great thing about LC's built-in support for arrays is that it's
> built-in.
> >>
> >> JSON has become used in so many other languages that we've forgotten
> why it was invented:  to serialize JavaScript objects as simply and
> efficiently as possible using features already built into the JavaScript
> interpreter.
> >>
> >> LSON is that for us, as much a with-the-grain approach to data handling
> in LiveCode as JSON is for JavaScript.
> > I just wish there was a human-readable, human-editable-in-a-text-editor
> variant of LSON :-)
> >
> > Someday, when I have some spare time, ...
> >
> > -- Alex.
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Alex Tweedly wrote:

> On 27/07/2018 20:17, Richard Gaskin via use-livecode wrote:
>>
>> >  Using arrays intigues me, especially if I can just keep it in RAM (It
>> > is a small amount of data for sure).
>>
>> One great thing about LC's built-in support for arrays is that it's
>> built-in.
>>
>> JSON has become used in so many other languages that we've forgotten
>> why it was invented:  to serialize JavaScript objects as simply and
>> efficiently as possible using features already built into the
>> JavaScript interpreter.
>>
>> LSON is that for us, as much a with-the-grain approach to data
>> handling in LiveCode as JSON is for JavaScript.
> I just wish there was a human-readable, human-editable-in-a-text-editor
> variant of LSON :-)

True, LSON is even closer to BSON ("Binary JSON") than JSON itself, with
all the machine-parsing efficiencies inherent in a binary format.

The world wanted a human-readable/writable form of JSON too, so YAML was
invented. :)

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Sannyasin Brahmanathaswami wrote:

 > Richard wrote " If that native form is an array, there may be no need
 > to do anything more than what LC already gives us straight out of the
 > box."
 >
 > I have been toying with this for some time, but like Alex said..
 >
 > "I just wish there was a human-readable, human-editable-in-a-text-
 > editor variant of LSON :-)"
 >
 > Keeps me in JSON

How often do you hand-edit array data?

Even JSON was found too cumbersome for efficient human reading/writing,
so YAML came along to fill that gap where human editing of raw data is a
priority.

One of the great things about computing in the 21st century is that we
have so many options to choose from, selecting the best fit for the
balance of human editing vs runtime efficiency as a given project requires.

--
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  [hidden email]                http://www.FourthWorld.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Data Persistence

Trevor DeVore via use-livecode
In reply to this post by Trevor DeVore via use-livecode
Use case is a major driver though.  If you have no need to hand edit a
file, then LSON is an efficient and easy way to store the data.  It also
has the benefit of being able to easily store binary data if needed.

On Fri, Jul 27, 2018 at 5:40 PM, Richard Gaskin via use-livecode <
[hidden email]> wrote:

> Alex Tweedly wrote:
>
> On 27/07/2018 20:17, Richard Gaskin via use-livecode wrote:
>>
>>>
>>> >  Using arrays intigues me, especially if I can just keep it in RAM (It
>>> > is a small amount of data for sure).
>>>
>>> One great thing about LC's built-in support for arrays is that it's
>>> built-in.
>>>
>>> JSON has become used in so many other languages that we've forgotten why
>>> it was invented:  to serialize JavaScript objects as simply and efficiently
>>> as possible using features already built into the JavaScript interpreter.
>>>
>>> LSON is that for us, as much a with-the-grain approach to data handling
>>> in LiveCode as JSON is for JavaScript.
>>>
>> I just wish there was a human-readable, human-editable-in-a-text-editor
>> variant of LSON :-)
>>
>
> True, LSON is even closer to BSON ("Binary JSON") than JSON itself, with
> all the machine-parsing efficiencies inherent in a binary format.
>
> The world wanted a human-readable/writable form of JSON too, so YAML was
> invented. :)
>
> --
>  Richard Gaskin
>  Fourth World Systems
>  Software Design and Development for the Desktop, Mobile, and the Web
>  ____________________________________________________________________
>  [hidden email]                http://www.FourthWorld.com
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
123