Page 1 of 2
Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 7:21 pm
by mikemc
Hi, I have a stack with a total of 100 data and label fields spread out over six cards. I plan on having about 50 different records.
What I need to create is a nice data storage solution that allows for a simple interface that will add new records, delete and modify
existing records. I have experimented with sql lite but with such a small database I have been told I can do it with livecode alone.
I just don't know how to do it and I can't find a lesson that fits my particular needs. Thanks
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 7:42 pm
by jmburnod
Hi
I can do it with livecode alone
Yes. You can do it with LiveCode alone.
I use an index in a simple .txt file with medias references
On open stack livecode import this file in a custom property end export this customprop to this file when the user quit.
add new records, delete and modify
That is an important step.
I understand that will be possible to import unknow files,that means managing files name, save changes or not etc... but it is a context where we learn a lot.
Best regards
Jean-Marc
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 8:04 pm
by mikemc
Sorry but I am relatively new to live code and programming and I don't understand how to
implement your response, but its nice to know it can be done. I am going to need a little
more guidance. Do I create a new card on the front end of my stack to use as the interface
to look at a list of existing records and to add an delete. I really wish there was a lesson on
this problem
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 9:04 pm
by dunbarx
Hi.
As Jean-Marc said, stick with LC. The size of your stack is not overly large at all; all actions will be instantaneous.
When you say you are "new" to programming, can you tell us more? For example, can you:
navigate from card to card?
do something like: put field 3 of card 5 into someVariable?
delete field "someField" of card 3?
Those types of actions? If not, you will have to do a bit of work before you can tackle your project. We will help every step of the way, but not write the app for you. The good news is that the learning is fun, and your project is simple and straightforward.
Craig Newman
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 10:13 pm
by mikemc
I am comfortable creating cards in a stack moving between cards creating fields and manipulating the
data in the fields for presentation purposes. The app is complete and works well manipulating a lot of dollar value defined
fields. Its just that right now it only holds one record. I understand how to define a global variable but have not worked
with them very much. I guess I need to know if the general design is to create the interface card with a list of records
and buttons to add, modify and delete records. Then when you select a record on this card you are able to access all the info
in that record on the following cards. I don't want someone to create it for me but I have been through the lessons on creating
simple data storage stack and using sql lite and can't find any others that address my specific design idea. This is the only other
way I know to approach the problem yes I am new to live code but I continue to learn although this problem has slowed me down for
several months.
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 10:28 pm
by SparkOut
ONE way out of many, which makes it simpler to expand and maintain:
Use a splashstack/launcher technique to call a runtime stack file, which can be saved on the fly. This would be the stack you are currently using.
Refactor your existing record display/manipulation to use a single card. A tabbed paging layout may be suitable, to show and hide relevant sections could be used.
Use this card as a template and clone it to add a new record ready for update. Add an option to delete selected cards.
Save the runtime stack after update so that when running next time the new records/deletes are retained.
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 11:17 pm
by dunbarx
Hi.
As Sparkout said, there are many ways to construct this. When you make your standalone, I also recommend the "Splash" stack method.
Long ago, there was a tendency to use individual cards as "records". Think rolodex. It was also common to use the first card as the interface to all the others, and there was never any navigation to those "record" cards. All functionality resided in the UI card, and all data was written to and read from the record cards directly. Just another way. With LC, it is possible to have everything in a table field or a dataGrid, which you can consider to be a tab and returned delimited field object that simulates a spreadsheet page. Yet another way...
This is a matter of style and comfort. Any approach would have the same power and flexibility. I would not use global variables at all, and I know why you mentioned it. There are better ways to hold and retrieve data, whichever way you choose. It might be useful to make a couple of test stacks that test each of these methods. Do the DataGrid last, if at all. That is an object that requires practice.
Write back with you progress and thoughts.
Craig
Re: Livecode internal data storage retrieval possibilities
Posted: Thu Oct 15, 2015 11:57 pm
by mikemc
Thanks for the input. Part of the functionally for the user involves having the data for a single record spread out on six
different cards they flip back and forth through. I will not get into it to much but each record represents a complicated
real estate deal that is best viewed on several cards. I have created my interface where adding a record takes me to the
first of the six cards and in theory modifying a record takes me to a scrolling list of record names where you can modify an existing
record or delete and existing record. I don't know if there is a way to save changes to a record in real time or if it has to happen upon
exiting the record or closing the app. The real time method would be the best also I only need to scroll through the records as
mentioned above by one field in the record. I guess I'm still not sure which storage vehicle would do this the best real time updating
is my first choice but saving changes is also possible. I think you have put me on the right track if you could suggest a storage vehicle
that might have some tutorials it would be greatly appreciated

.
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 2:08 am
by mikemc
I am deciding between and array and a data grid right now I have some time to learn but
don't know much about either method. Can either one of these methods be updated real time on closefield when entering data or is this just
a pipe dream and I will need to create a save function Thanks
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 4:40 am
by dunbarx
An array is a type of complex variable that can have multiple layers of data. It is a tool, but is not directly pertinent to the way in which you construct your stack. It can be, but It is for later.
I will believe you when you say that six cards are required to best "view" the information present in a single "record". Is it always six cards? Is the first card the "main" card? Will the format for each of the six cards be common to all records? These are the questions that must be answered in order to be able to form the structure of your stack. Think about this:
Would a series of groups of six cards (1-6, 7-12, 13-18, etc.) one set per record, be useful in building the whole? A bit cumbersome, since if you deleted the third record, say, then you would have to either delete those six cards, or mark them as inaccessible. The good news is that if you delete six cards, the following ones "fall" forward in order, fillling the "gap".
What about one card per record? What if each card contained a group of controls, each group mimicking the controls on one of the six cards? You could hide and show each group as required, in the same way that you navigated to a certain card. If you deleted a record, you need only delete one card. Same filling of the gap. If you clone a card, to create a new record, you will also clone all those groups.
You can save any time you wish, live. That is a non-issue.
...also I only need to scroll through the records as
mentioned above by one field in the record.
Not sure what this means. Are you using the word "record" consistently? You can use it any way you want to, but it must be consistent.
Anyway, everything you could possibly want to do is open to you directly in LC. The way you are asking certain questions makes me think you do not quite understand how "live" LC is, or rather, how simple and direct almost any action you can imagine can be implemented with a line or two of code. Why not make a test stack with just a few controls on it. Make a button that shows and hides various combinations of those controls, and see if that is useful and pleasing. I would much rather work on one card that is married to a record, and show various suites of controls.
As to how you store the information in any particular record, there are several ways. Fields and custom properties are best, since they survive sessions. You might even try your hand at arrays, as per your previous post, but do that later.
Editing any of the data in any control in any group on any card is a couple of lines in a handler. That is not your problem. Unless I am missing this entirely, your problem is to design a working construct. Once you have that, we can add functionality as required, without limit.
Craig
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 7:14 am
by SparkOut
Anything you do on six cards can be done on one card with six groups. Make each group fit the card, and instead of going to another card, show the right group (and hide the rest).
Management of your records will be a lot simpler to match one record with one card. But it can be done anyway, so you are not forced to do anything.
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 5:28 pm
by mikemc
I guess I don't know enough about how to use groups like individual cards. I like the idea
of one card being one record because it is simple to create the data base however it would require
and redo on the design of the app. One thing I am curious about is moving between groups on a single card.
How do you hide five groups and access only one group at a time? I am sure this is simple I just don't know how.
To answer from above right now all six cards are unique but pass and recalculate imputed data between
each other.
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 7:06 pm
by dunbarx
Hi.
Try this on a new card with a button and two fields. In the button script:
Code: Select all
on mouseUp
if the visible of fld 1 then
hide fld 1
show fld 2
else
show fld 1
hide fld 2
end mouseUp
Craig
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 10:14 pm
by mikemc
Hi Craig
I didn't have any luck trying this. I put fld 1 and fld 2 on a card created the button add the script but
when I used the button nothing happened. Did I miss something? Also will this work with six different
groups of fields? Thanks
Re: Livecode internal data storage retrieval possibilities
Posted: Fri Oct 16, 2015 10:22 pm
by dunbarx
Hi.
This is because I did not take the time to see if my handler passed muster. It is missing an "end if" statement at the end:
Code: Select all
on mouseUp
if the visible of fld 1 then
hide fld 1
show fld 2
else
show fld 1
hide fld 2
end if
end mouseUp
But didn't you see that the handler did not compile? Not completing the if-then construct will throw a compile-time error.
Craig