Skip to main content
Known Participant
January 6, 2011
Question

SplitStory script seems to be broken

  • January 6, 2011
  • 1 reply
  • 1712 views

I am typesetting a book that needs to have separately numbered footnotes for each short section; they typically end in the middle of a page, so I might have the last footnote from one section in the upper part of the page and the first of the next in the lower part.

Physically, I can get the result I want by inserting a blank 1-line split-column paragraph between the two sections, which forces the earlier note(s) to precede it. The problem is getting the numbering to start again from 1 in the new section. ID only allows section breaks at the top of a page, so I need to split the story repeatedly (potentially nearly 200 times in the whole book) whenever the section division comes in the middle of a page.

I thought the SplitStory script would do the trick, but it doesn't seem to work. Whether I have an insertion point in the text or select the frame the text is in, the script fails with the error message "AppleScript Error!    Error Number: -2741    Error String: Expected "," or "}" but found identifier    Engine: Default    File: Applications/Adobe Creative Suite CS5/Adobe InDesign CS5/Scripts/Scripts Panel/Samples/AppleScript/SplitStory.applescript".

Any advice?

This topic has been closed for replies.

1 reply

Inspiring
January 6, 2011

The script works OK here. Try opening it in AppleScript Editor (choose Edit Script from the Scripts panel flyout menu) and run it from there -- then report which lie of the script the error is happening on.

Known Participant
January 7, 2011

For some reason the faulty behavior has disappeared today. Yesterday, I restarted the computer at least once, but continued to get the same error; in AppleScript Editor the word "range" in the second line of the script proper (not counting the initial comments) was highlighted. The one major change in my system was upgrading Mac OS X to 10.6.6 overnight.

Today the script works, but it turns out it isn't doing what I need: I hadn't quite understood from the descriptive comments that it separates every frame into a separate story (as well as wiping out all overset text, which I did get). What I need is to be able to split a story into two (no more) at a precise point in the text. If I have to make that point coincide with a break between two frames, I can live with that (though it would be a heck of a lot easier if I could simply position the text cursor at the point where I want to make the break). An even better solution, which I expect is unrealistic, would be to split the story at every occurrence of a particular paragraph style. (The sections I need to split up are of variable length, often covering multiple frames.)

I have no expertise in scripting. Can you suggest a way to achieve what I'm after? Has anyone already produced a suitable script?

Thanks,

Jeff

Inspiring
January 9, 2011

Please be patient. I said I could live with that, but also that I have no expertise in scripting. So: I know that I need to manually ensure that the point where I want to split is at the end of a frame. Please advise me how to

break the link between two text frames, and split the story between the two resulting text flows

because I don't know how to achieve this, either by hand or by scripting.


OK, suppose you have the cursor somewhere in some text in a frame. When you run the following script, all text beyond the selected insertion point will moved to the following frame, and the link between the two frames will be broken:

tell application "Adobe InDesign CS5"

set theSel to item 1 of selection

set theOffset to index of theSel

set theStory to parent story of theSel

set theFrame to item 1 of (parent text frames of theSel)

set nextFrame to next text frame of theFrame

set next text frame of theFrame to nothing

set parent story of nextFrame to ""

move (text from character theOffset to character -1 of theStory) to after parent story of nextFrame

end tell