don't allow the size of your script to exceed 650 KB !!!

I won’t burden you with my mass of a mess of a script here, but just wanted to clue you in to something that I found out the hard way. Needless to say, the script I’d been working on was pretty lengthy - suddenly I’ve come to realize it’s TOO LENGTHY. A check of the file size puts it currently at 704 KB (which BTW is about all I can do with this thing now, cause the script editor won’t open it any more). Here’s how it went down.

 I'd been compiling this script for quite some time, running it and working out the kinks along the way. Saved it, opened it, closed it, all with no problems. Last night I declared the script to be finished and saved it again, this time under another name so that I could do some minor corrections here and there (and add a few things). Four hours later I'd just about polished it off when the trouble started. I knew something was up when all of the sudden Script Editor wouldn't compile as per my request. I thought that was strange, so I tried saving to see if I could get it to check my script that way. It saved alright but still wouldn't compile. . . o.k. so I'll close the file and reopen it, surely it'll get it together then, right? - Well, no. Actually it just managed to ruin my whole script! Upon re-opening I get the following error:

 Unable to read the file because the script is not editable (it was saved as run-only).

 no matter what I do, I cant get it to open :mad:

After a lot of scrambling and some cursing, I concluded that I must of inadvertently saved my script as run-only (most likely when I saved my orginal script under a new name, not really paying any attention). At least my pre-update version of the script still opened. Why there's an option to save a working script as "run-only" and why that would've been set to default  . . . . . . .  I went to bed without any dinner, determined to wake up this morning and re-do it all over again. So I'm plugging away, making most of the same changes as I did the night before when all of the sudden it happens again, script editor suddenly won't validate my script! I KNOW somethings up now, so I copied my script over to a text document for safe keeping, to find out what I'd already suspected - my new script won't be able to be re-opened either cause it was saved as run-only. Only that it wasn't! How stupid would I've been to make the same mistake twice, I know for a FACT that "run-only" was not checked when I saved this new updated version. I even started with a fresh script, copied the code from my text doc and guess what, wouldn't re open!!!

   Thus my conclusion: if ever your working along and suddenly Script Editor stops compiling your script, check ur file size (from what I can derive 650 KB seems to be the threshold the prognosticators at Apple came up with). If you find yourself over that limit and want to save your work for future reference, dump your script over to something able to handle "such a computing size" - else you'll be sorry!

  Anyone else ever run into this? Any advice/insight you can offer other then the obvious one of breaking my script up into smaller scripts? Please let me know. I'm using Script Editor v. 2.1.1.

I’m curious if this is a Script Editor or AppleScript thing. I switched to Script Debugger a long time ago. I’d be happy to do a check for you if you’d like to send me the script that won’t compile.

Must be one heck of a monster, my 1440+ line script is only 56 kb, and some folks here thought that was looooong. :wink:

Script Editor has always had a limit on script sizes. It used to be 32KB, so count yourself lucky. :slight_smile:

That’s the main reason I switched to Script Debugger years ago - and have never looked back.

You can download a trial at

Another option may be XCode

thanks guys for the link to Script Debugger. I downloaded a trail and quickly checked it out - here’s an update; while IT WILL save and reopen my 704 KB script (934 KB when saved through the 'Debugger) with no problems, I still cant get it to compile the script’s text. It did however open my first draft of the script that I thought was lost forever (the one Script Editor told me last night was run-only)! But now I got TWO scripts that arn’t quite finished and now much harder to read w/o the text-coloring validation. Looks like the run-only thing was a Script Editor bug having to do with file size BUT the fact that I still cant compile means that it must be an appleScript thing too. All in all though, I think the script still should run without any problems - its just that I’m so close to being finished I want to be sure there wont be any other problems.

and yeah this thing is kinda nuts, its setup to do numerous searches through my photoshop and illustrator files and then build hundreds of local HTML pages based on specified file groupings and other attributes. Some of the HTML pages have extensive java-script in them too, which really contributed to my ‘too many lines of code’ problem.

Sounds beefy :slight_smile: Post that bad boy to code exchange and I’m sure someone who would find it useful would do some optimizing or at least splitting it up into a main script/libraries.

Ha, ha - while I don’t have a problem sharing my script (not sure MacScripter would even take it) I don’t really have the time or the inclination to try and go through it ALL at this point. Not sure if the code exchange is the proper forum, cause like I said its not quite finished and was set up for such a specific task that as a whole I cant see how it would be useful to much of anyone. That being said if someone wanted to go though and clean it up for me - BE MY GUEST! :smiley:

edit - Just tried to post it but was told it can’t exceed 64 KB :lol:

I’d be interested in taking a look at it. You might be able to stream line and shorten it by using scripting libraries instead of having everything coded in the one script. Also you might be able to build some sort of database or text file that you could load to element some of the text overhead. Both of these might make it both easier to work on and easier load and compile. If you want to e-mail me a copy I will take a look at it when I get a chance.

This would lead me to the simple belief that the script has legitimate compile errors. What error did it give?

I’ve never know SD to falsely refuse to compile without there being legitimate problems. In other words, every time I swore up-n-down it was SD’s fault, posting code for folks to examine here proved it to be squarely my own fault. :rolleyes:


I agree, 99% of the time its usually my fault, but I don’t think its the case this time. I really think its a size issue. No error message, it (in theory) compiles the script b/c the button turns off and doesn’t let me compile a second time (like it would during normal circumstances) BUT both script editors fail to organize and color code the text - just leaves me with purple text. I can go down to the end of my script and delete a few handlers or something (to cut down size) and everything works fine! Interesting that both editors behave the same way with the lengthy script.

Try e-mailing Latenight Software…they are very helpful with e-mail support of the product. He might be able to give you some idea.