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: Paul Berkowitz <email@hidden>
- Date: Mon, 25 Jul 2005 11:04:24 -0700
- Thread-topic: My first question, please be gentle (stack overflow)
Title: Re: My first question, please be gentle (stack overflow)
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:
Matt Gregory wrote:
>This all works fine while running in the Script Editor (OS X 10.3.9). But when I save the script as an Application and run it, I get the error saying the script "could not be saved because the stack overflowed."
http://lists.apple.com/archives/applescript-users/2005//Jul/msg00178.html
http://lists.apple.com/archives/applescript-users/2005//Jul/msg00244.html
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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 (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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden