Skip to main content
Alan Houser
Community Expert
Community Expert
July 18, 2022
Answered

Extendscript: moving chapter to end of FrameMaker book

  • July 18, 2022
  • 1 reply
  • 286 views

Colleagues,

I'm trying to figure out _why_ the Extendscript below works, to move a chapter to the end of a FrameMaker book.

I understand that the value of "NextComponentInBook" is always zero for the last book component. But when I explicitly set this property to zero for an arbitrary book component, the current "last" book component already has a "NextComponentInBook" value of zero.

Does Extendscript perform housekeeping to set the "NextComponentInBook" value of the _previous_ last chapter to the _new_ last chapter, automatically?

Perhaps my confusion is in thinking about the list of book components as a conventional linked list, in which I would need to do this housekeeping myself.

TIA,

-Alan Houser

 

 

// Get the active book
var book = app.ActiveBook;\
// Add new chapter to book. '0' argument puts it first
var NewLastChapter = book.NewSeriesBookComponent (0); 
// Set the name of the new chapter
NewLastChapter.Name = "lastchapter.fm";
// Move new chapter to the end of the book.
NewLastChapter.NextComponentInBook = 0; 

 

This topic has been closed for replies.
Correct answer frameexpert

Hi Alan, I am not sure if I understand your question, but after NewLastChapter moves to the end of the book with your code, the properties of each component "refresh" so that the previously last component's NextComponentInBook property is updated to the NewLastChapter object. Hmm, I am not sure how understandable my answer is.

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
July 18, 2022

Hi Alan, I am not sure if I understand your question, but after NewLastChapter moves to the end of the book with your code, the properties of each component "refresh" so that the previously last component's NextComponentInBook property is updated to the NewLastChapter object. Hmm, I am not sure how understandable my answer is.

Alan Houser
Community Expert
Community Expert
July 18, 2022

Hi Rick - Your answer makes complete sense. My mental model of lists of objects with "previous/next" properties didn't quite match what I was doing with FrameMaker. I like your "refresh" analogy. I thought I would/should need to update the previously-last book component myself, but FM handles that. Thx!