Re: Trouble with variable persistance
Re: Trouble with variable persistance
- Subject: Re: Trouble with variable persistance
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 04 Jun 2001 19:27:03 -0700
On 6/4/01 3:45 PM, "Romulus Barabas" <email@hidden> wrote:
>
>> I have to declare a, b, c as
>
>> global variables at the beginning of the script, otherwise subroutines
>
> won't
>
>> be able to do work on them and pass them on.
>
>
> You don't have to declare variables as global or property, you can pass
>
> local variables as parameters to your subroutine.
>
>
> If you want to use globals or properties and don't want persistance you can
>
> reset them when your script ends or using the "on quit" handler.
>
>
>
>
How do I reset the variables? I don't know the syntax.
>
There's no such thing as a special 'resetting' syntax. It's the normal 'set'
syntax - he's just writing normal English here in this email, not
AppleScript syntax. He just means to set them again, in the normal way, to
whatever you want them to be. If the original setting of the property, for
example, was "", as in
property anyOldThing : ""
and then in the script it gets set to all sorts of things, then at the end
of the script, just write
set anyOldThing to ""
Quite frankly, you could do that at the beginning of the script to be safe,
as you would with a global (you can even just make it a global instead of
property, if you are setting it every time at the beginning and don't need a
property's persistence ). Just if you're loading this script, or some of its
handlers, from another one would you need to be very careful. I've missed
the beginning of this thread so I don't know if you have things like that to
be concerned about, but I'd doubt it if what you're hoping is to _prevent_
persistence.
--
Paul Berkowitz