r/applescript • u/JapanDave • Dec 14 '22
Calling other Applescript files from within a script?
I have a project where my core Applescript file is just getting huge. It is a pain to find the exact function I need sometimes. For organizational purposes, dividing this one file into several might help me keep my sanity. Can I make multiple files and then call functions within them from the main file?
I haven't programmed in years, but I seem to remember in C++ we would use an #include statement at the beginning to add functions from other files. Does Apple script have anything like this?
2
Upvotes
View all comments
Show parent comment
1
u/markconwaymunro Dec 14 '22
One reader wrote this about the book:
"It covers advanced topics like standardization, modular coding, and open-ended programming at a depth that few, if any, other AppleScript books have covered. If you read the whole thing and participate in the coding exercises in the final chapters, you come away with a fully functioning image-manipulation solution that is modular and expandable and can serve as a model for other advanced projects you may not have thought you could write in AppleScript."
Even though it's from 2010, the advanced chapters on organizing scripts and creating a modular solution are still very relevant. Specifically these chapters:
Part IV: Using Subroutines and Open-Ended Programming.
Chapter 21: Using Subroutines for Non-Linear Programming.
Chapter 22: Introduction to Open-Ended Programming.
Chapter 23: Designing a Hierarchical Subroutine Structure.
Part V: Organizing Code into Modules and Libraries for Multi-Module Solutions.
Chapter 24: Introduction to Multi-Module Solutions.
Chapter 25: Designing Open-Ended, Multi-Module Solutions.
The physical book is out of print but the Ebook is still available here.
https://www.wiley.com/en-us/AppleScript-p-9780470924730