Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Cannot access text insets in a doc

Guest
Dec 18, 2012 Dec 18, 2012

Windows 7 / FM 11 / ESTK CS6 / ExtendScript 4.2.12

I am trying to perform a pretty simple task--iterating over the docs in a FrameMaker book and converting all text inset instances to their pathnames--but it won't allow me to access the text inset objects using FirstTiInDoc and NextTiInDoc.

For example, the code snippet is:

var book = app.ActiveBook;

var doc = book.FirstComponentInBook;

while (doc.ObjectValid())

{

var inset = doc.FirstTiInBook;

while (inset.ObjectValid())

{ /*inset processing*/

inset = inset.NextTiInBook;

}

doc = doc.NextBookComponentInDFSOrder;

}

I *know* there are text insets in the documents, a combination of external FM files and plain ANSI text files, all sourced and resolvable without issues. But ExtendScript just isn't assigning the Text Inset objects from .FirstTiInBook. It also throws an exception if I try to use ObjectValid() on an undefined variable (this might be the correct behaviour, please let me know if it is).

Am I using FirstTiInBook wrong somehow? The above snippet is lifted almost verbatim from Adobe script examples.

Many thanks,

JR

TOPICS
Scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 19, 2012 Dec 19, 2012

Hi JR,

I haven't done this with ES before and I haven't studied your code in great detail, but I can see one glaring error. The call:

var doc = book.FirstComponentInBook;

...will not get you a document object. It will get you a book component object that is like a pointer to the document. You'll need to use the component object to get the document path, then use the path to get the document. If the document is open, you can use the path to find the currently-open file. If it is not, you can use the path to open the document.

As a brief and untested example, I'd suggest that you need something like:

var comp = book.FirstComponentInBook;

while (comp.ObjectValid())

{

  var path = comp.Name;

  / * some code here to get the doc object from the path */

 

  var inset = doc.FirstTiInDoc;

  while (inset.ObjectValid())

  {  

      /*inset processing*/

      inset = inset.NextTiInDoc;

   }

 

  comp = comp.NextBookComponentInDFSOrder;

}

One other thing... I'm not aware that there is a "FirstTiInBook" or "NextTiInBook" property for any object. You found that in the documentation? I've never seen it. If it does exist, my suspicion is that it is not what you think it is. But I don't know that for sure.

Russ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 20, 2012 Dec 20, 2012

Hi Russ,

Thanks for your reply. I might be naively trying to handle the returned doc pointer so I will investigate that.

The *Ti* properties are document and Text Inset properties, as described in the FrameMaker 10 Scripting Guide (page 222, and page 398). They *should* behave as i've described: at least, there's nothing in the rather minimalist documentation to suggest otherwise.

Cheers,

Jay.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 21, 2012 Dec 21, 2012

Hi Jay,

The point is that you are not getting a document pointer, so you can't be handling one, naively or not. Also, on page 222, I see no mention of FirstTiInBook... I think you might have wished that into existence..

Russ

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 23, 2012 Dec 23, 2012

On page 222 of the named guide there is most definitely a FirstTiInDoc document property.

JR

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Dec 24, 2012 Dec 24, 2012
LATEST

Hi JR,

You aren't looking closely enough. FirstTiInDoc does exist. FirstTiInBook does not. The latter of which is what you have in your sample.

RUss

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines