having a script remember stuff

is it possible to have a script remember the last input it got before it quit? for example, if i were to write one that added two digits, would it be possible to have it remember the answer when i activarewd it again?


Here’s the example scirpt from AppleScriptLanguageGuide.pdf, p. 157:

property theCount : 0
set theCount to theCount+1
display dialog "The value of theCount is: " & theCount ¬
as string

BTW, global variables or any variable is saved to the next run. You use the property to set the variable to an initial value.


There is a caveat. If you recompile the script, your saved property will revert to its original value as per the first instruction above.

You could also just write a file to save any data you want, and have your program check to see if the file exists every time it runs, to retrieve whatever data you saved out on the previous run.