Store data into a field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Store data into a field
Hi everybody, I have some data which I save into a field. If I close my app and re-open it, the field appears empty. I just need to know how can I store them into that field so that later I can modify them? Replies are most appreciated...
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Store data into a field
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Store data into a field
Thanks FourthWorld for your reply; but the scripts seems to store the data into a file or folder. Instead I want to save them into the field. Is it possible?
Re: Store data into a field
Apparently notalemrantareq wrote:Thanks FourthWorld for your reply; but the scripts seems to store the data into a file or folder. Instead I want to save them into the field. Is it possible?

No, standalones cannot save themselves at all, you must use external files!
Best
Klaus
Re: Store data into a field
How about using your main stack as a 'splash screen'.... which opens when you open your app... Have a button on the splash screen that opens a sub-stack and closes the 'splash screen'... You are now effectively using the sub-stack as the 'main' stack of your application..
In the stack script of your sub-stack, save the changes you have made, they will be there the next time you run your app.
be well
Dixie
In the stack script of your sub-stack, save the changes you have made, they will be there the next time you run your app.
Code: Select all
on closeStack
save this stack
end closeStack
Dixie
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Store data into a field
Dixie's comments are spot-on. In fact, I rarely use text files for storage, preferring the richness of stack files.
Traditionally, it's considered good practice to separate code, data, and UI, so changes to any one of them can be made robustly and efficiently without affecting the others.
In most of my apps the document window the user sees is cloned from a template on the fly, and populated to display data stored in properties in a stack file. This way I can add new features or even completely overhaul the UI without affecting the user's data.
But for simpler apps there's often no harm in just storing the data in a field, so long as the stack holding the data is stored in a separate stackfile from the executable (since OSes don't allow apps to modify themselves), and providing that the data stack is stored in a folder that has write permissions (which may exclude the Applications (Mac) or Program Files (Win) folders for non-admin accounts.
If you find that you need to save your data stack in a user-writable folder, you can use the specialFolderPath function to find the path to the user's Documents folder on Mac and Win, e.g.:
Traditionally, it's considered good practice to separate code, data, and UI, so changes to any one of them can be made robustly and efficiently without affecting the others.
In most of my apps the document window the user sees is cloned from a template on the fly, and populated to display data stored in properties in a stack file. This way I can add new features or even completely overhaul the UI without affecting the user's data.
But for simpler apps there's often no harm in just storing the data in a field, so long as the stack holding the data is stored in a separate stackfile from the executable (since OSes don't allow apps to modify themselves), and providing that the data stack is stored in a folder that has write permissions (which may exclude the Applications (Mac) or Program Files (Win) folders for non-admin accounts.
If you find that you need to save your data stack in a user-writable folder, you can use the specialFolderPath function to find the path to the user's Documents folder on Mac and Win, e.g.:
Code: Select all
set the fileName of tMyClonedStack to (specialFolderPath("Documents")&"/MyData.rev")
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn