Skip to main content
K.Daube
Community Expert
Community Expert
May 28, 2019
Question

ExtendScript documentation considered harmful

  • May 28, 2019
  • 4 replies
  • 1825 views

Dear all,

In the scripting documentation (Scripting Guide, FDK documentation) you find the same attributes/properties in the description of neary any object.

For example: NextGraphicInFrame; NextGraphicInDoc, NextGraphicInGroup is listed for Doc, Frame, Line, PolyLine, Ellipse etc.

I wanted to treverse the graphic objects within an anchored frame:

  • oDoc, oFrame is the current environment.
  • oGraphic is a selcected grahic item (polyline) within the frame
  • I want to select the next graphic in the frame.
  • oFrame.NextGraphicInFrame creates an invlid object
  • oDoc.NextGraphicInDoc creataes an undefined object
  • oGraphic.NextGraphicInDoc finally is the solution

Why is it necessary to fiddle around with such outrageous information?

Neary any basic function must be verified by experimental scripts - or the help of You all.

I'm in the comfortable situation having time for such experiments - but anyone in need of solution in due time...

Klaus

4 replies

Participant
July 14, 2025

Tried to take a glimpse at Extendscript yesterday to create a custom script for InDesign.
It's a shame what Adobe is doing here, namely to base the scripting language on a 20+ year old version of Javascript.
Honestly i am not very familiar with Javascruipt but with Java. The random appearance of the weakly typed - or better poorly typed - code makes me sick.
I guess i better let Chat GPT do the job and just focus on debugging and tweaking.

Community Expert
July 14, 2025

Hi Thomas,

This is the FrameMaker forum and not the InDesign ExtendScript forum. You might post your comment there.

Best regards, Winfried

JonBe
Inspiring
June 13, 2019

Hi Klaus,

I feel your pain. As others have said, Adobe to have not put that much effort into the object model documentation for FrameMaker with Extendscript IMO. I find myself referring to the FDK documentation whenever I am working with Extendscript. And then there are the bugs, the memory leak we have discussed elsewhere, and now it looks like Doc.Find has changed again, or been fixed from 2017, sigh.

As for the small FrameMaker market, I have two customers with 100 licenses between them, with FrameMaker as the key element in a custom structured authoring solution. To them it is critical.

Jon

frameexpert
Community Expert
Community Expert
May 28, 2019

A couple of things about linked lists in FrameMaker: Apparently, they are somehow memory efficient and are from the early days when computers didn't have a lot of RAM. It's true that some of the lists don't necessarily reflect document order; for example FirstPgfInDoc/NextPgfInDoc; FirstGraphicInDoc/NextGraphicInDoc.

However, some lists do reflect some kind of order: FirstTextFrameInFlow/NextTextFrameInFlow and its more useful FirstTextFrameInFlow.FirstPgf/NextPgfInFlow. Of course, this skips tables and the paragraphs in the them, so you sometimes have to work around that.

There is actually some order to FirstGraphicInFrame/NextGraphicInFrame; these are determined by stacking order of the objects in the frame. FirstGraphicInFrame will be the bottom of the stacking order if there are multiple graphics in the frame.

In your case: you have a selected graphic which could be the FirstSelectedGraphicInDoc (I say could because there could be more than one graphic selected). If that graphic happens to be at the top of the stacking order in the frame, then NextGraphicInFrame will be undefined. That is probably the cause of your confusion. You could go "down" the stacking order by trying PrevGraphicInFrame.

Or you could jump back to the parent frame and start from there:

oGraphic = oDoc.FirstSelectedGraphicInDoc;

oFrame = oGraphic.FrameParent;

// Switch to the first graphic in the frame which might not be the one selected.

oGraphic = oFrame.FirstGraphicInFrame;

while (oGraphic.ObjectValid ()) {

    // Do something here?

    // ...

    oGraphic = oGraphic.NextGraphicInFrame;

}

-Rick

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
May 29, 2019

Jang and Rick - thank You both for the detailed explanation - especially the existance of various lists for the same object!

Oh really, it is learning the hard way round...

But still I can't wind Adobe's wreath for the kind of script documentation...

Klaus

Legend
May 29, 2019

It is an absolutely true statement that the documentation is weak. And that may not be true enough, because I think any complete newcomer would struggle heavily to even get started. It seems that those of us who have had success with ExtendScript did so because we previously had success with the FDK or FrameScript, and/or overwhelming expertise on the inner workings of the product. We generally understand the scripting guide because we already understood it. I imagine that somebody at Adobe already recognized that, but that somebody else also recognized that the audience is small and the book does not merit the expense to improve. I can understand that reasoning. I think the much bigger fault is the fact that the audience is small. It's just another example of a powerful differentiator that sets this product well apart that Adobe seems to think is better kept a secret. It amazes me the things that Adobe promotes instead of the most useful features of the product, like its API and the general structured interface. Were it not for either of those, I would not be using the product today. The vast majority of users are missing out on the best parts of the product and it seems Adobe wants to keep it that way.

I should have kept this political rant to myself, but I couldn't resist. Thanks for putting up with it.

Russ

4everJang
Legend
May 28, 2019

Hi Klaus,

Most FM objects are organized in linked lists. Some are pointing in both directions (Next and Prev), others are not. When you start from a selected object, there is no way of knowing where that object is in the list of graphic objects in the same frame.

The various linked lists in which the same object may appear may not be in the same order. For instance, the paragraphs in the main flow of the document are listed from top to bottom. The graphic objects in a document may well be organized by the moment of their insertion, which has nothing to do with the order from top to bottom (I don't know this and I have not tried to figure it out, but I would not count on the order being in the direction of the document). With graphic objects in a frame there is no way to tell which one is first and which is next in a linked list.

It could simply be that the selected graphic in your frame is the last one in the linked list of graphic objects in that frame. So you should follow the link from the object to its parent and then find the first object of the same type in that parent - that is the start of the list. Follow that to the end of the list (the first invalid object) and you have traversed all graphic objects in that same frame. Using the NextGraphicInDoc gets you to all the graphic objects in the entire document, of course. If you then try to figure out whether they have the same parent, you are doing much more work than you need to.

Find the start of the rainbow first, then follow it to the pot of gold at the other end. :-)

I hope this sheds some light on why there is so much complexity in FM. I have had a peek inside Word and Excel and I can tell you that we are the lucky ones !

4everJang