Re: My first question, please be gentle (stack overflow)
Re: My first question, please be gentle (stack overflow)
- Subject: Re: My first question, please be gentle (stack overflow)
- From: Matt Gregory <email@hidden>
- Date: Mon, 25 Jul 2005 15:09:19 -0400
Ok, that makes more sense. And it explains why Script Editor
itself is also complaining about not being able to save the file ... in
both cases it is trying to persist my giant global variable(s). I
obviously need to spend a little more time in the documentation.
Excellent explanation! Thank you!
matt.
On 7/25/05, Paul Berkowitz <email@hidden> wrote:
No. AS doesn't persist local variables between runs. It persists properties (pre-defined globals) and globals between runs.
The part that is a bit confusing and non-apparent is that AS treats undeclared variables at the top level
(i.e. not in a handler) as globals for persistence purposes, although
not for scope*, while undeclared variables within handlers
(subroutines) are treated as local variables to that handler. So the
two ways to avoid the problem you're seeing is to make sure they're not
globals by either
- Explicitly declaring them as local at the top of the script, or
- Putting
what would be the top level (implicit or explicit run handler) of the
script into a subroutine and calling that with a single line.
That makes them all local variables, which the script does not try to
save at the end, so there's no change to the file and no stack overflow
either.
[* It is possible (though not advised) to declare a global within a
handler. Therefore undeclared variables at the top level need to have
this quasi-global attribute of being lookable-up when you declare a
global within a handler. I.e. they really do have a sort of "potential"
global scope, but it's not operative unless declared global somewhere.
I expect that's how undeclared top-level variables end up being treated
as globals when the script quits, and AS tries to save them.]
--
Paul Berkowitz
From: Matt Gregory <email@hidden>
Reply-To: Matt Gregory <email@hidden>
Date: Mon, 25 Jul 2005 13:44:26 -0400
To: has <email@hidden>
Cc: <email@hidden>
Subject: Re: My first question, please be gentle (stack overflow)
OOOOH! I didn't realize that AS tries to persist local variables
between runs ... that idea sounds strange to me, but I guess there's a
good reason ... I'll have to take a closer look at the docs on it.
That's a little gem to keep in mind! I should be able to
localize all my variables or even make multiple writes to the output
file instead of one big write at the end.
This helps immensely, thank you very much! Those threads didn't
turn up during yesterday's archive search session. I'll be more
careful next time. Your assistance is very much appreciated!
Thanks again,
matt.
On 7/25/05, has <email@hidden> wrote:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden