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

Find text and apply paragraph format tag in Framemaker 11

Community Beginner ,
Jan 29, 2016 Jan 29, 2016

Copy link to clipboard

Copied

Help!!!

I'm trying to automate finding text in a FM11 file and tagging it with a specific para tag. Once it's tagged, I want to be able to search for the same string again and delete it. The search will include wildcards. I'm moving Word files over and bringing them in with manual numbering of paragraphs. So, when they come in, they have "2.3.4.5" in front of the paragraphs for instance. I want to search for all numbers at beginning of paragraphs, tag all those with the appropriate para format (from a catalog) and then delete the manual numbering.

Right now we do this manually, by using Find/Replace and using wildcard search strings to find (such as "\P[1-9]*.*.*.*[0-9]", which will find all para numbering with 4 digits at the beginning of a para), and then using the Change By Pasting option to paste in a para tag from the catalog. Then we rerun the same search and delete the text, leaving only the para tag formatted numbering. It works great, but errors can arise if the search string in put incorrectly or if the numbers are not deleted (in this case, it is found on the next search and retagged improperly). For example

I work for the Air Force gathering inputs from the field and creating publications out of them, so there's no profit motive here, just trying to be efficient. Any help is greatly appreciated!!

thanks in advance

b

TOPICS
Scripting

Views

1.1K

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

Mentor , Feb 02, 2016 Feb 02, 2016

Hi Brian,

I'm just guessing here because I've never done this before, but... I see there is definitely something wrong with your assignment of Find property values. The way you have it written, you are attempting to assign two properties to a single array space. This is why you apparently have to remove those two lines to make the find work, because they are overwriting the FindText property. Here is my guess at how it should be:

    findParams = AllocatePropVals(2);

  

    findParams[0].propIdent.

...

Votes

Translate

Translate
Mentor ,
Feb 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

b,

There are quite a few things going on here and your question is open-ended. I can give you some tips, but I'm not able to write the script for you. Maybe someone else would have the time. Anyway, there have been several posts on this forum about how to do a search with ExtendScript. In fact, the thread just behind yours by Klaus Daube has some sample code for this. Regarding the application of a paragraph format, it is pretty simple. You can find an example in the "02.06 DOC_-_Change_pgf_format_font_size.jsx" script here:

FrameMaker ExtendScript Samples - West Street Consulting

Hopefully that can get you started. Unless someone else is feeling generous, it's likely that you are drifting into paid consultancy to ask for much more. That said, I hope you can get this worked out. Myself and others are happy to answer more specific questions about focused issues.

Thanks,

Russ

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 Beginner ,
Feb 01, 2016 Feb 01, 2016

Copy link to clipboard

Copied

‌thank you for the response. I've been fighting my way through it, cobbling together from examples the components I need. I figured out how to to do a search replace of text and will be delving into para formatting over the next coup,e of days. The big hurdle was just getting started and getting my head around the syntax.  I'll post once I get further along so maybe it can be tightened up.

brian

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 Beginner ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

So, below is what I have so far. I am able to get it to find text, apply a para format, and then add new text while deleting the old text. In the example below, I can find "3.2", format that para to "chsubpara8", add text "XYZZZ" and delete the "3.2".

What I can't figure out is how to get the use wildcard constant to work. Any ideas?

#target framemaker

    var doc=app.ActiveDoc
    var docStart = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf ; 
    var tloc = new TextLoc (docStart, 0); 
    var searchString = "3.2";
    var replaceString = "XYZZZ";
   
    // setup find parameters 
   findParams = AllocatePropVals(1);
  
    findParams[0].propIdent.num = Constants.FS_FindText;
    findParams[0].propVal.valType = Constants.FT_String;
    findParams[0].propIdent.num = Constants.FS_FindCustomizationFlags; //The script only runs without these two lines
    findParams[0].propVal.valType = Constants.FF_FIND_USE_WILDCARDS; //The script only runs without these two lines
    findParams[0].propVal.sval = searchString;
   

   var foundText = doc.Find(tloc, findParams);
   pgfFmt = doc.GetNamedPgfFmt ("chsubpara8");
   var props = pgfFmt.GetProps();
  
    while (foundText.beg.obj.ObjectValid()) { 
          //alert(foundText.end.offset); 
          //do stuff to found text
      tloc = new TextLoc(foundText.end.obj, foundText.end.offset);
      var pgf = tloc.obj;
      pgf.SetProps (props);
      doc.AddText (tloc, replaceString);
      doc.DeleteText (foundText);
                //end do stuff to found text 
        
      foundText = doc.Find(tloc, findParams);    
    //}
}

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
Mentor ,
Feb 02, 2016 Feb 02, 2016

Copy link to clipboard

Copied

LATEST

Hi Brian,

I'm just guessing here because I've never done this before, but... I see there is definitely something wrong with your assignment of Find property values. The way you have it written, you are attempting to assign two properties to a single array space. This is why you apparently have to remove those two lines to make the find work, because they are overwriting the FindText property. Here is my guess at how it should be:

    findParams = AllocatePropVals(2);

  

    findParams[0].propIdent.num = Constants.FS_FindText;

    findParams[0].propVal.valType = Constants.FT_String;

    findParams[0].propVal.sval = searchString;

    findParams[1].propIdent.num = Constants.FS_FindCustomizationFlags;

    findParams[1].propVal.valType = Constants.FT_Integer;

    findParams[1].propVal.ival = Constants.FF_FIND_USE_WILDCARDS;

Anyway, let me emphasize again that this is a guess and I did not test this. I am pretty sure, though, that the solution is somewhere along this path.

Russ

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