An Applescript error appending to list objects - I believe this is a bug?
Step 1: Paste this script into your Script Editor and Save it to any file name you want to give it.
Step 2: Run the script and hit Command-S to save the script.
-------
set xLimit to 8144
set aList to {}
repeat with I from 1 to xLimit
set end of aList to I
end repeat
-----------
This should work just fine.
Step 3: Now change the value of 8144 to 8145 and run the script
-- no problem either ... UNTIL you TRY TO SAVE THE FILE.
Control-S, File/Save and File/Save as ...don't work.
Script Editor says "The document xxxx.scpt could not be saved"
I also tried this on a different computer with the same result.
Both machines are up on the latest version of Leopard and I am running
on my Imac which is configured as follows:
Model Name: iMac
Model Identifier: iMac8,1
Processor Name: Intel Core 2 Duo
Processor Speed: 3.06 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 6 MB
Memory: 4 GB
Bus Speed: 1.07 GHz
Boot ROM Version: IM81.00C1.B00
SMC Version: 1.30f1
Now I also tried this with Script Debugger 4.5.2 (Latest release)
Here the error on saving is more precise:
" Cannot Save Document
Signaled when the runtime stack overflows
(errOSAStackOverflow:-2706)"
The error is in CocoaSpeak but a Stack Overflow is potentially dangerous to
execution stability. I dont feel comfortable with just trying to ignore this.
Page 233 (appendix B) of the Applescript language guide is not more descriptive
than the above.
Anybody else know about this? Am I doing something wrong in trying
to append to an existing list? I've tried other variations before posting
this note. Some of them are:
1) Initializing aList with 1 or 2 elements first -- same result but xLimit
has to be set to 8146 (for 1 element) or 8147 for (2 elements) to fail.
2) Using a reference to aList such as
set refaList to a reference to aList
No luck here either --- Same result.
3) Putting ()'s around aList or using my I or my alist constructs
all yield the same result.
4) Just for completeness I tried the following dreadfully slow technique
inside of the loop.... ah yes, you can go above 8150 but somewhere on or
before 8190 it results the same as all the other ways.
set aList to aList & {I}
Even the sledgehammer failed.
You will not notice this error if you make a change to the script and then save it.
It will only be obvious if you run the script and try saving immediately
afterward -- without making any changes.
Ken Higgins
Imac, Mac OS X (10.5.4), Windows 2000 Advanced Server with Domain and Private DNS DHCP servers