RAH! Help! No more code lines!

Help! I have posted a message earlier on this board because I needed help for a Patch Loader program. Well, since the interface sucked and that I wanted to add some features, I have been rewriting it using Dialog Director 0.7 and other stuff to make it much better. Alas, this cost a lot of code lines, and I just bumped into something every programmer fears: no more lines! I can’t type a single caracter more in the Script Editor window! Arg!! I’m toasted!
Fear not, I know it’s possible to run code from an external script, but I can’t make it work.
So, do any of you AppleScript “geek” knows how I would be able to call a specific handle from a external script file? Since my style of programming implies the “all-variables-are-global” thing, I don’t think I’ll have to pass any parameters.
Thanks to anyone who can help me! When I’m done, I’ll post my script in the Script Of The Week. Hehee, a 50 pages more script, cool huh?

set script_containing_code to (load script alias_to_this_script)
tell script_containing_code to execute_magic_code()

You can load any script as an script object, then use its handlers/methods…

“load script” is part of “Standard Additions”

Then, “tell” this script, as if it was an app.

eg, if this script contains:

beep

then

tell script_containing_code to run

if this script contains:

on do_something()
   beep
end do_something

then:

tell script_containing_code to do_something()
   --> beep!

Also, you can send/retrieve variables. Eg, your script contains:

on displayThis(thing)
   display dialog thing
   return button returned of result
end displayThis

And your caller-script:

tell script_containing_code to displayThis("Hello!")

Then, this will return results of your called-script to your caller-script

:slight_smile:

JJ

You can also pass variables into your external script by doing this:

Make sure your external script has properties set to it.

property SomeProperty : ""
property AnotherProperty : ""
property YetAnotherProperty : "" 

Then in your interface script include something like this:

set ExtScript to load script "Mac HD:Some Folder:Some Script File"
--now pass the data by setting the properties of the loaded script
set SomeProperty of ExtScript to "A recipe or something nice"
set AnotherProperty of ExtScript to "Whatever"
Set YetAnotherProperty of ExtScript to "Pulu Cee Mugumba"
run script ExtScript

Best,

You can also get Script Debugger from Late Night Software http://www.latenightsw.com/

It doesn’t have Script Editor’s 30K text limit, and it has lots of other nifty features for serious AppleScript development.

(No, I’m not affiliated with Late NIght Software, just a happy customer :slight_smile: )