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

Running ExtendScripts on FM and MIF Files.

New Here ,
Mar 13, 2017 Mar 13, 2017

Copy link to clipboard

Copied

Hi,

I was trying to run a script to extract all Paragraphs in a fm file with a specific tag name and I could see that I did not extract texts for many paragraphs.

However when I saved the fm file as a mif file, and on running my script hereafter I was able to extract all paragraphs including paragraphs that were hidden.

Please let me know why is there such a difference between running on a FM file and a MIF File.

Secondly, If i were to update the MIF files with new paragraphs (and text ), could I save it as an FM file and use it interchangably.

Thanks,

Sebin

(Attaching my Script)

    var doc = app.ActiveDoc;

    var pgf= doc.FirstPgfInDoc;

    var count = 0 ;

    while (pgf.ObjectValid()){

        if (pgf.Name == 'Specific_Par_Name')

        {  

             count += 1;

             var test = pgf.GetText(Constants.FTI_String ); 

             var text, str;

             text = "";

             //$.writeln(test);

             for (var i=0; i < test.len ; i +=1)

             {

                 var str=test .sdata.replace(/^\s+|\s+$/g, '') ;

                 //var str=test .sdata;

                  text = text + str;

                  //PrintTextItem (test);

             }   

       

         //  file.writeln(text);

         }

       // $.writeln(paraname);

        pgf=pgf.NextPgfInDoc;

}

$.writeln(count);

//file.close();

TOPICS
Scripting

Views

665

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Mar 14, 2017 Mar 14, 2017

There should be no difference between an FM binary file and a MIF file after they are opened and sitting in memory. When you open a MIF file with FrameMaker, the MIF parser should convert it into a binary representation, which is what your script would operate on.

One possibility for the differences: Does your file have conditional text that may have been hidden before you saved as MIF? It could be that when you opened the MIF file, the MIF parser made all of the conditional text shown.

Votes

Translate

Translate
LEGEND ,
Mar 13, 2017 Mar 13, 2017

Copy link to clipboard

Copied

In the FM doc, you should be running the script against the first paragraph in the flow (typically Flow "A", but FM docs can have many flows). The first paragraph in the document may not be the first thing that you see in on a Body page. The Body page shows the flow content.

Votes

Translate

Translate

Report

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
Engaged ,
Mar 14, 2017 Mar 14, 2017

Copy link to clipboard

Copied

Arnis, is there really a difference processing FM binaries and MIF files, when they are opened in FM. I wasn't aware about that, yet, but I also can't really imagine with my way of thinking how FM works in Background.

@sebinkur: Yes you can add paragraphs and save MIF back to binary format.

Strange

Votes

Translate

Translate

Report

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
LEGEND ,
Mar 14, 2017 Mar 14, 2017

Copy link to clipboard

Copied

Depending upon how the FM file was created, saving as MIF organizes and cleans up the internal database, so I think it's possible that some items in the document order may be re-arranged vs. accessing those in the flow order. However, my scripting experience is much more ad hoc and most of my stuff is generated as MIF first via Miramo, so I'll defer to your and Rick's expertise on this.

Votes

Translate

Translate

Report

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
New Here ,
Mar 14, 2017 Mar 14, 2017

Copy link to clipboard

Copied

Thank you. I was able to do that.

Votes

Translate

Translate

Report

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
Community Expert ,
Mar 14, 2017 Mar 14, 2017

Copy link to clipboard

Copied

There should be no difference between an FM binary file and a MIF file after they are opened and sitting in memory. When you open a MIF file with FrameMaker, the MIF parser should convert it into a binary representation, which is what your script would operate on.

One possibility for the differences: Does your file have conditional text that may have been hidden before you saved as MIF? It could be that when you opened the MIF file, the MIF parser made all of the conditional text shown.

Votes

Translate

Translate

Report

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
New Here ,
May 01, 2017 May 01, 2017

Copy link to clipboard

Copied

LATEST

Hi Rick,

My script does have conditional text, so I do have a check in my script to extract text if the "ConFmtisShown". This does extract everything when I'm running on the mif file.

As Arnis suggested, there may be many flows in the document, probably due to which I am only able to extract a subset of all the text that I could otherwise extract from a mif file. Could you let me know how I could modify my script to accommodate all the flows or an other way I could tackle this problem?

Thanks,

Sebin

Votes

Translate

Translate

Report

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