Re: mac script size revisited
Re: mac script size revisited
- Subject: Re: mac script size revisited
- From: Andrew Oliver <email@hidden>
- Date: Wed, 09 Apr 2003 16:20:23 -0700
Pre Mac OS X versions of Script Editor had a limit of 30,000 characters[1]
in a script. I haven't seen any discussion that leads me to believe it's any
different in Mac OS X, but it may be. I don't use Smile, so I don't know its
limits (if any)... Emmanuel?
The only script editor I know that has no practical limits on script size is
Late Night Software's Script Debugger which I've used back in Mac OS 8.x to
create scripts over a megabyte in size (before I got smarter :) ).
Either way, it does sound like you're hitting a limit somewhere. Breaking
your script into separate libraries would make a lot of sense. It's easy to
do.
First, move whatever functions you like into a separate script. For sanity's
sake, make sure the functions are self-contained and don't rely on globals,
etc. that might not be available.
Then in your main script:
set scriptLib to load script "path:to:script library"
Now, anywhere in your script you call a function/handler by:
set myVar to scriptLib's functionName()
Obviously, substituting the appropriate function name and providing any
relevant parameters for the function.
You can create multiple script libraries grouped by functionality. For
example, I've compiled a math library holding various math-related handlers,
a string library with string handlers, etc., and I load them in as needed.
This approach also helps keep your focus on the primary script, and greatly
reduces compile times.
Andrew
:)
[1] Yes, I know technically, 32,767 is the character limit in Script Editor
1.x, but as I understand it, it started throwing error messages once you
reached 30,000 characters since it maintained a buffer zone, and compiling
often increases the number of characters in a script as indentation and
formatting adjusted the text flow.
On 4/9/03 3:48 PM, "Michael Glasser" <email@hidden> wrote:
>
I have a fairly big script... over 5000 lines and about 240KB. When I
>
try to check the syntax it tries for a few seconds and then does
>
nothing. When I try in Smile, it gives me an error code -108, which on
>
Apple's site is listed as "Out of memory".
>
>
I have 1.5 GB of mem, am running OS X 10.2.4... I find it hard to
>
believe that memory is really the problem.
>
>
I can remove the last 50 or so lines of the code and the syntax checks
>
out OK... the same is true for the 50 lines removed. It fails as soon
>
as I add back any of the several functions that are in those 50
>
lines... so it does not seem to be based on faulty code.
>
>
Ever since I added functions I have not been able to run the code as a
>
program... runs from the beta script editor just fine, but gave errors
>
when run as a program.
>
>
Any ideas? What is the best way to call functions from another script
>
if I have to split my code into multiple files?
>
>
Any help is appreciated...
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.