Re: Trouble with variable persistance
Re: Trouble with variable persistance
- Subject: Re: Trouble with variable persistance
- From: "Romulus Barabas" <email@hidden>
- Date: Wed, 6 Jun 2001 03:03:08 -0400
>
>> 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
Sorry about this whole thread. There's no "Trouble with variable
persistance", just "Trouble with bad scripting". I was missing a set
sequence for those variables, which got lost while the script was getting
stuffy.
It may not hurt though to know if there is any way, besides recompiling, to
set a variable to nothing, not an initial value, just nothing, forgotten.
Romy