Re: Duration of local variables
Re: Duration of local variables
- Subject: Re: Duration of local variables
- From: Emmanuel <email@hidden>
- Date: Wed, 23 May 2001 12:25:32 +0200
At 10:08 +0200 19/05/01, Marc K. Myers wrote:
>
>
If I run the following script repeatedly in Script Editor or as an
>
applet, the variable xPrime in the run handler increments. The variable
>
xPrime in the reset() handler does not. Can anyone tell me why? I
>
didn't expect the value of a local variable to be retained from
>
execution to execution. I'm using AS 1.6 under OS 9.1.
>
>
on run
>
try
>
set xPrime to xPrime + 1
>
on error
>
set xPrime to 1
>
end try
>
reset()
>
display dialog "[run] " & (xPrime as text)
>
end run
As you observe, the "run" handler is not really a handler. It runs in the
context of the script. Expect it to behave nearly as if there was no "on
run" nor "end run" line.
Emmanuel