property not persistent

I’m trying out setting a property for the first time, but I can’t get the property to be persistent.

--this is part of my script
property mySnippet : ""

set mySnippet to (choose file) as text

I saved the script as an app, but that did not help.

What I’d really like is to have the actual file “mySnippet” as an alias, so the script would find it if it got moved.

Thank you.

Paeon, you are doing it right. Your variable mySnippet is persistent as is. I’m trying to think of why it’s not working for you and can think of only 2 reasons, either 1) you are resetting the variable somewhere else in your script or 2) you are editing the script in script editor and pressing the “compile” button. Every time you press compile in script editor the persistent variable is forgotten and reset to the initial value.

Run this several times and you will see it works fine…

property mySnippet : ""
display dialog "Before choose: " & mySnippet
set mySnippet to (choose file) as text
display dialog "After choose: " & mySnippet

So you see nothing is wrong with the persistent variable.

Thanks, guys. Script works perfectly now.