Page 1 of 1
Where to store text lists?
Posted: Mon Nov 16, 2020 8:34 pm
by Francesco77
Good evening from Germany,
my name is Frank and I am quite new to LiveCode.
I would like to build an application in which I have to read text from some comma separated text lists to fill some array variables which are used in an educational game.
The reason for this is that I need text lists that can be edited without the need of the LiveCode engine with a simple text editor.
Now I wonder where to put and store these text lists in LiveCode. For testing purposes I created some text fields and put the text items into them.
Of course the user should not see these lists so I made them invisible for the user. This works but I am not sure if this is the best practise way to achieve what I want.
Is there a special place (a special card in stack or some place else) where objects should be stored which the user should not see or interact with?
Sorry for my bad English, I hope I could explain to you what I want to know.
Thanks in advance for your help.
LG F.
Re: Where to store text lists?
Posted: Mon Nov 16, 2020 8:56 pm
by richmond62
to put and store these text lists in LiveCode
AS far as I am aware the only way you can STORE text docements IN a LiveCode standalone
would be in a macOS standalone as it is a disguised folder full of components.
Re: Where to store text lists?
Posted: Mon Nov 16, 2020 10:34 pm
by bn
Welcome to the forum Frank.
As far as I understand you want to store text in Livecode that the user can not access.
If the text is prepared before building the standalone and does not change later on then storing the text in a hidden field is perfectly alright.
If you want to store text between runs of a standalone you would have to save it out to an accessible folder. For example "Documents". See specialFolderPath in the dictionary.
The standalone can not write text to its app folder but it can read from text added to the standalone at compile time. Here again it would probably be the easiest way to store the text in a hidden field or a field in a sub stack and not to bother storing text at build time in the app bundle.
Kind regards
Bernd
Re: Where to store text lists?
Posted: Mon Nov 16, 2020 10:59 pm
by dunbarx
Hi.
There is another way to save data between sessions apart from an external file that Bernd suggested, and that is in a stack file attached to the executable file. That way everything stays as stacks within LC. This is called the "splash stack" method and is often a matter of personal style, sometimes depending on the size or format of the data.
Otherwise, I agree with Bernd to keep it simple. In a standalone, even an experienced LC developer would have a hard time exposing a hidden field.
Craig
Re: Where to store text lists?
Posted: Tue Nov 17, 2020 9:29 am
by Francesco77
Thank you very much for your help
Bernd, you are right. I only need to store these texts within the application. They cannot be accessed or changed by the user.
I used to work with Macromedia/Adobe Director in the past and remember that there were so called "casts" in which all objects were stored in a neat data grid where hundreds of objects could be seen at a glance. I wondered if there is something like that in LiveCode.
Since I need only 10 or 15 of these text fields this time I will store them as suggested on a card in the stack that the user cannot access.
Thanks again for the support
LG Frank
Re: Where to store text lists?
Posted: Tue Nov 17, 2020 3:29 pm
by Klaus
Buongiorno Francesco,
there is also a german LC Forum, with quite low traffic, but in german.
https://www.livecode-blog.de/forums/for ... ode-forum/
You can also use "custom properties" to store your data INSIDE of your stack.
But some (hidden) fields will surely fit your needs, too.
Best
Klaus
Re: Where to store text lists?
Posted: Tue Nov 17, 2020 6:53 pm
by jacque
Another way is to store the text in custom properties. This is usually my preferred method. If you want a nice single compilation of text, store the text in an array and set a custom property value to the array. This is far faster than field access and doesn't require any additional stacks or controls.
If you need help learning about custom properties, we're here.
Edit : I just saw Klaus's answer. We think alike.
Re: Where to store text lists?
Posted: Tue Nov 17, 2020 11:12 pm
by kdjanz
Custom properties won't work on the mobile main stack though will it? Changing the custom prop would modify the signed stack wouldn't it?
Re: Where to store text lists?
Posted: Tue Nov 17, 2020 11:55 pm
by FourthWorld
You could use a separate stack file for storage. But if all you're storing is an array, maybe just save the array to disk. See arrayEncode and arrayDecode for serializing into a form suitable for transfer and storage.
Re: Where to store text lists?
Posted: Wed Nov 18, 2020 12:47 am
by jacque
kdjanz wrote: ↑Tue Nov 17, 2020 11:12 pm
Custom properties won't work on the mobile main stack though will it? Changing the custom prop would modify the signed stack wouldn't it?
I thought the OP is storing static data at build time. Maybe I misunderstood this:
I only need to store these texts within the application. They cannot be accessed or changed by the user.
If the data is dynamic then it can still be stored in a custom property at runtime, but it can't be saved. On the other hand, if it's dynamic, it probably doesn't need to be saved.