Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Entering carriage returns in extendscript

$
0
0

So, I've been able to fight my way up to a point to where I can search for a string, apply a para format, then replace the found string. Works great!  Thanks, Russ, for the assist...

 

Now, does anyone know how to enter a carriage return as part of a find/replace? I've tried to just use "\r" and several combinations of that but can't figure it out. I need to find a specific text string, go to the end and enter a carriage return.

 

Also, along similar lines, when using the find function in the UI, you can put \P (for beginning of the para) and other criteria (like \t for tab stop). Does anyone know how to use those features in script?

 

Below is what I'm using for the search and apply formatting, just for sharing purposes, it works fine, just looking to extend features. It could probably be done a bit more elegantly, but if it works...

 

//This is the chsubpara5 search and tag
    var doc=app.ActiveDoc
    var docStart = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf ; 
    var tloc = new TextLoc (docStart, 0); 
    var findParams = new PropVals();
   // setup find parameters 
    var searchString = "[1-9]*.*.*.*.*.*.*[0-9]";
   
    findParams = AllocatePropVals(2);
  
    findParams[0].propIdent.num = Constants.FS_FindCustomizationFlags;
    findParams[0].propVal.valType = Constants.FT_Integer;   
    findParams[0].propVal.ival = 4;
   
    findParams[1].propIdent.num = Constants.FS_FindText;
    findParams[1].propVal.valType = Constants.FT_String;
    findParams[1].propVal.sval = searchString;
     
   pgfFmt = doc.GetNamedPgfFmt ("chsubpara5");
   var props = pgfFmt.GetProps();
   var foundText = doc.Find(tloc, findParams);        
   var counter = 0
  while (foundText.beg.obj.ObjectValid()&& counter < 100) { 
          
    tloc = new TextLoc(foundText.end.obj, foundText.end.offset);

//alert (foundText.beg.offset, 2);
   if (foundText.beg.offset=="0")
   {
   var pgf = tloc.obj;
   pgf.SetProps (props);
   //doc.AddText (tloc, replaceString);
   doc.DeleteText (foundText);
      }    
      
    foundText = doc.Find(tloc, findParams);
    counter ++;
    }
//End of chsubpara5 search and tag


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>