Porting your InDesign Script into IdExtenso — Step 1
September 07, 2021 | Tips | en
So, you have the root idea and a basic code for your next InDesign script. All is fine. It works so well that you're now planning to release it, which opens additional questions: Will it work everywhere? How do I trace risky functions? What if I need to integrate new features later on? How do I deal with persistent user settings? How to add a basic interface? How will I localize the dialog in other languages? Can I make my script available in a dedicated menu? Will it work in a JSXBIN package as well? Can I obfuscate my code?…
Preamble
IdExtenso is the place to go if you want to take your InDesign script to the next level. But this is a framework, and as many frameworks it might intimidate at first.
You may think: “My code is ok, I don't want to install extra stuff, I will gradually fix the issues and improve the functionalities as the requests arise, I can do that!” Sure you can! IdExtenso is not a magic enhancer, it won't translate your code into some ultimate dialect.
Simply consider it a toolbox. Many recurring needs and issues have been already addressed here. And all IdExtenso bricks converge on improving the frame and the robustness of your own script, in whatever InDesign version and system environment. That's the deal.
Now let's move on to concrete things. In this series, I will try to recap and illustrate the migration of a minimal sample script to IdExtenso. From the scratch code to the final product, all stages will be covered. (So you can see for yourself if the task is as insurmountable as you thought at the beginning ;-)
Prepare The Core Routine
Before downloading and installing anything, your first exercise is to format your InDesign script as a single function (the usual main routine) being called at the last line of the code. This function achieves the fundamental task. Of course it may have some arguments and many dependencies. In most cases, the “fundamental task” leads in fact to various optional subtasks which depend on the context, the user options, etc. Anyway, we still need something of an entry point, and that entry point is your core routine.
• Give it a name (for example, the name of your project.)
• Document it properly.
• Make sure dependencies are declared before it and invoked from it.
Note. — A “dependency” can be seen as a subcomponent (value, object, routine) and should be thought as a private feature of the core routine. As long as IdExtenso doesn't come into play, you may need to declare these data or references globally. We'll clean that up in a future episode.
• Invoke the core routine at the last line of your script, passing some default settings if needed.
• Test your script in InDesign.
Our Base Example
Given below in its original state is the script that we shall port into IdExtenso. It creates dots—in fact, small circles—on every path point of the selected spline item(s):
It's your turn!