Data Persistence

Mike Bonner bonnmike at gmail.com
Sat Aug 4 16:20:53 EDT 2018


Putting text into a field pro-grammatically doesn't fire the openfield and
closefield handlers so yes, you'd need to add code to your button.  You can
either write the code directly, or you can use send (or dispatch) and have
the field do it.. IE send "closefield" to field "whateverfield"...   But if
it were me, I'd just add the code to the button itself.

Actually, I'd probably have the code once, in the card or stack script that
accepts parameters like the long id of the field, data to be saved and
whatever else so that you have a single handler that will work for all of
your saves.

Something like

on saveIt pLongId,pText
    -- code to save pText and associate it with control pLongId
end saveIt

Then you can do..
on closefield
     saveit (the long id of me),(the text of me)
end closefield

Or in a button..
on mouseup
put "Whatever text" into field "myField"
saveit (the long id of field "myField"),the text of field "myField"
end mouseup

Just some thoughts.





On Sat, Aug 4, 2018 at 1:28 PM John McKenzie via use-livecode <
use-livecode at lists.runrev.com> wrote:

>
>  A little less busy now so I can look at my app some more. As you mat
> recall I was asking about data persistence.
>
>  Thank you to the additional people who welcomed me. I contrast this
> with the time I asked a question on Usenet about a scripting language I
> was learning and the first reply told me I was awful (true, which is
> why I was asking questions) and to come back and only ask questions
> when I have the script I posted working.
>
>  As for contributing brains. Yeah... I supposed I could fake
> that part for awhile. Just do not ask for kidneys as you will get
> nowhere there.
>
>  Klaus thank you for mentioning closefield. Did not notice it before
> and it seems like it would be just the thing for me. The data is
> simple, so I think I will start out by trying to save it all in an
> array and doing so every time there is an entry or change to an entry
> using closefield.
>
>  And that brings me to today's follow up question. In some cases I have
> a button that when pressed put the time inside the neighbouring text
> field. So when a plane lands I pressed the button labelled "ATA" and it
> puts the current time into a text field next to the ATA button. How
> would that count as focus?
>
>  Would having the app place something into the field put focus on the
> field?
>
>  What I am really wondering is when it comes to the buttons can I leave
> them be because the text fields have code to save their info when the
> focus leaves or should I add code to the buttons to tell them after
> placing the info into the text field, save same info to an array?
>
>  Thanks.
>
>
> _______________________________________________
> 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