Friday, August 26, 2005
Master of the Universes
Perhaps I've been watching too much Stargate, but it occurred to me that one way of explaining what scripting is all about is to think of your script as being master of three parallel universes:
These objects behave in just the ways you would expect based on your experiences dealing with them in your hands on use of them through the user interface. The difference for the scripter is that your script (I'm going to say "you" from here one) can deal with these elements directly rather than through the intermediary of the user interface.
That'll do for now. It's time for me to go watch some more Stargate!
- The JavaScript Universe
The InDesign Universe
The File System Universe
These objects behave in just the ways you would expect based on your experiences dealing with them in your hands on use of them through the user interface. The difference for the scripter is that your script (I'm going to say "you" from here one) can deal with these elements directly rather than through the intermediary of the user interface.
Scripts are Not Macros
Some "scripting" languages are little more than user interface commands strung together. But this is not the case with scripts that drive InDesign. Indeed, there are cases where the behavior of the user interface can confuse a scripter:- In the UI, you address application preferences and defaults only when no documents are open. In a script, you can address them all the time. Indeed, if you want to address the preferences and defaults of a document then you must explicitly do so. A script does not have an implicit relationship with the active document. If that's what you want to work with, then you must say so.
Also in the UI, some attributes are automatically linked together. Have you noticed how when you change a stroke weight to zero the swatch automatically changes to None? Well that happens because the UI is a program and it does that to save you trouble. When you script this function, you are the programmer and so you must deal with both settings.
That'll do for now. It's time for me to go watch some more Stargate!