Sunday, May 9, 2021

#1 2020-09-17 12:44:07 pm

Jeffkr
Member
Registered: 2005-11-05
Posts: 483

Can an AS reach its limit in terms of lines or global variables?

I have an issue related to an Applscript that contains over 5,000 lines of code and over 100 global varialbes. It appears as if it can no longer be saved using the default Script Editor app - Using a trial version of Debugger "might" save it once, but then I typically seem to have issues saving the script a sequential time, or it results in the following alert from the getgo:

Debugger 4.5 alert:
Cannot Save Document
Signaled when a runtime internal data structure overflows (errOSAInternalTableOverflow:-2707)

Debugger 7 alert:
Cannot Save Document
invalid component instance (badComponentInstance:-2147450879)

Does anybody know what might be the prime culprit without digging deeper into the script? For instance, is it more likely related to the exteme amount of lines of code or is it more likely related to the amount of global variables?

Is there any way to fake Applescript out so you could have global variables called from another script that might help my cause?

Or better yet, is there some software I can purchase that would circumvent this script compiling issue alltogether?

Thanks,
-Jeff

Offline

 

#2 2020-09-17 06:14:27 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6627

Re: Can an AS reach its limit in terms of lines or global variables?

Your script is (way) too big. AppleScript has to keep track of every thing in a script, and it has a limit. Try breaking some of your code into script libraries you can load.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2020-09-18 07:27:22 am

Jeffkr
Member
Registered: 2005-11-05
Posts: 483

Re: Can an AS reach its limit in terms of lines or global variables?

Thank you very much Shane for you reply. This is what I unfortunately expected to see and I will therefore attempt to break apart my script. Thanks again and have a nice weekend.

-Jeff

Offline

 

#4 2021-04-09 09:28:16 pm

publiclee
Member
Registered: 2012-08-07
Posts: 5

Re: Can an AS reach its limit in terms of lines or global variables?

I'm also getting the bad component dialog with a script of only a thousand or so lines.

On this issue of managing complexity and file size in a world where macOS security is continually reducing coding freedoms a colleague has suggested that I refactor my script so that the run handler is lean and basically just calls a bunch of handlers and logs the result.

He also reckons that globals and properties are unloved and that wherever possible I should declare them locally and if needed elsewhere just pass them as parameters in the handler.

I'm thinking this refactoring process is the root cause of my current situation as some handlers now have dozens of local variables declared so that I can track them in the debugger.

I've also tried and failed to implement Nine Garvey's CustomQsort as a library object and so it now sits in the script as well. Consequently I'm reluctant to use libraries.

Am I following best practice with these actions?

Model: iMac 2019 27" 40Gb RAM
Browser: Safari 605.1.15
Operating System: macOS 10.14

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)