Revert after Getting an Error in an InDesign Script
Doug wrote with a problem he was having with the Split Story script (which ships with InDesign, inside the Scripts panel):
When I attempt to run the script it comes up with a javascript error (Number 11274; String: Object is Locked).
He figured out that problem pretty quickly himself… the frames with the threaded story (that he was trying to split) were locked on the master page. But then he discovered a bigger issue:
The problem though, is something I discovered by accident later. It appears that whenever this error box pops up, instead of removing threading it actually duplicates all the threaded text boxes. I discovered up to three separate copies of each text box on each page (far too late to Undo so I had to delete them all manually).
This perfectly illustrates a point every script-user should understand: Running a script is different than choosing a menu item. In many cases (though not all), a script will run through a series of several or many different steps to accomplish its task. Those tasks are actually recorded in InDesign’s Undo history, so you could step back through them if you wanted to.
In the case of the SplitStory script, one of the steps the script takes is to first duplicate each frame in the story. Later, when it tries to delete the original frames, it finds that one of them is locked and it “errors out” — it stops running. But it doesn’t go back and clean up after itself. And even if you Undo once or twice, you won’t get back to the original state.
That’s why it’s often a good idea to choose File > Save before you run a script like this, and if it errors out before it finishes, then choose File > Revert. That puts you right back to square one, ready to fix the problem (then save) and try the script again.
Thanks David. That makes sense. I’ve been diligently saving before performing this script since discovering this side effect of the splitstory script.
I think I’ll avoid setting locked text frames in the master page from now on, I tend to want to move them later anyway so it doesn’t really help me much.
Cheers,
Doug
That sounds great, Doug. I want to emphasize that what you did was not unusual or illogical. The use of locked frames or running the script multiple times is not “wrong” in any way. The revert thing is just one of those dirty little secrets that most InDesign users don’t know about. Thanks for giving me a chance to share it here!
Even without a script it is easy and accidental to generate frame copies. Not sure how it happens but I have had it occur a couple times with CS4. Only noticed it when edited text in the previous column of the top frame appeared oddly in the next frame. Ghosted on top (or below) the text in the originally copied frame below. But at least I watch out for this bug now.
In CS4 Adobe added support for undoing a script and would prevent something like this from happening. It’s not all that difficult for the scripter to add it to the scripts either, I’m surprised Ole didn’t do it.
Fred,
I have not used that, though I have written a number of scripts. One thing that I have found is that if I need to automate something for myself I can usually do it pretty quickly, but it is very specific in it’s use. If I need to hand it off to someone else I can spend as much or more time writing in error checking and validation into the script than I do writing the actual functional portion of it. Even then there is usually something that I missed and need to go back and fix later.
An example of this is a script that created picture boxes, worked fine on my computer as well as other’s that I tested it on. I handed the script off to another user and all of a sudden they had a 1 pt black rule on them because she had her default picture frame set that way. A simple fix, but I never would have thought to have to add that in until after I cam across the problem.
I forgot to mention in the blog post above that there is a great and easy way to find duplicate objects in your documents (like those that Doug had… two objects right on top of each other):
The Quality Assurance panel (part of the Blatner Tools suite of plug-ins) finds them easily and warns you about them!
Hi Jerome,
I totally agree with you. I realize new things can come up. I am not blaming Ole for the error. I am blaming him for not putting in the necessary steps to put the user back to where he started in case he runs into an error.
Pre CS4 this was a very difficult thing to do, but now in CS4 it is pretty easy in most cases with UndoModes.
FWIW, FiddleScript makes it really easy to make a script undoable in one step…
Using Mac InDesign CS4, I do not see File > Revert. I seem to recall it existed in prior versions. Has it moved? The reference book on ID CS4 that I am using has no index entry for Revert.
@Larry: It is still there for me… perhaps you need to quit and restart, or rebuild your preferences? Strange!
Indeed it is still there. Wasn’t it Barnard’s Star, or perhaps it was Pluto, that was discovered only when the astronomer (Clyde Tombaugh in one of those cases) looked at the sky and at his plates sideways?
I may have been looking too hard. Or something. Can’t rewind reality to find out.
Thanks. Fini.