Where can I store user data ?

Hello,

Is there some place to store user data ? (something like register in M$ Windows) or should I create a file and put everything there ?

Regards

You can store data in the preference folder in the user’s library, or in a property variable.

Property variables are added into scripts like so, at the beginning of a script:

property x : missing value

These always save values for the next time the same application is opened.

Here is an example:

property x : "This goes into the property \"x.\""

set returned_from_dialog to (display dialog "What text do you have to store?" default answer x buttons {"Nevermind", "OK"} default button "OK")
if button returned of returned_from_dialog is "OK" then set x to text returned of returned_from_dialog
if button returned of returned_from_dialog is "Nevermind" then set x to "You have canceled the dialog."

~

The preference folder is a folder in the user’s library folder that is normally used to store permanent preference data. You can save files into this folder. I’m not going to show you how to save files because there are PLENTY of topics on MacScripter that show how to save lists, text, numbers, ect. onto files, and take them out, too.

Not always. The values are preserved always only if the script is saved as application.

Oh yeah, sorry. Thanks, Stefan.

Or if it’s run from Script Menu, DragThing, TextWrangler etc., or is a folder action. Properties aren’t automatically saved if they’re in a script loaded into a another or if they’re run using ‘run script’ or from the script menus of some other applications, such as PowerMail.