Saving information in stand alone application

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cdated
Posts: 1
Joined: Tue May 08, 2007 8:20 pm

Saving information in stand alone application

Post by cdated » Wed May 09, 2007 1:33 pm

I have created a series stacks to use for student scheduling and combined them into a single stand alone application. The problem I am having is that changes made to the schedule are not being saved after the application quits. Each student's schedule is on an individual card with each period's course in a separate field. Changing a course uses popup buttons that inserts the new course in the appropriate fields. Everything works correctly except that any changes that are made are not saved when the application is quit. When it is restarted, the schedule has reverted to it's original state.

Is there a way to keep the new information? Preferably without using databases.

If you need more information, please let me know.

Thank you in advance for any assistance.

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Wed May 09, 2007 2:15 pm

Unfortunatly once compiled into a standalone, the mainstack is unmodifiable. Usually what I do to store the user's changes, is to use a preference file placed in the preference folder or (only on OS X) inside the application bundle. My scripts for doing this can be found in this post.

Here is an excerpt from the old Rev documentation (which I thought was much better than the current):
A standalone application cannot save changes to itself, so you store preferences or data for a standalone application by saving the data in a separate file. There are two ways to save data:

• Use a stack to store and display the data, and use the save command to save the stack in a file. This approach is best if your application is based on working with documents: the saved stack file becomes your document. You re-open the stack with the go command.

• Put the data in a file using the file’s URL as a container (or use commands such as write to file and export to save the data), then read the data from these files when your application starts up. This approach is best if the data you want to save consists of settings or similar data.

:idea: Tip: To find the Preferences folder, use the specialFolderPath function.

Post Reply

Return to “Talking LiveCode”