How to find the last pasted paragraphs FMP?

I'm sticking FMP several objects at once in a file (a file of changes to the sections containing the changebars) in the main text flow. I want a separator line to go at the end of each pasted section, so I try to insert one after the paste operation. But instead of a line between each section, all lines are added at the end of the file, after all the sections. So if there are 3 glued sections at the end of the file are three lines. My code is below, do you know how I could fix this?

Thank you, Mark

function copyPasteChanges (doc, chgRange) {}

Select the section with changebar and copy it.

doc. TextSelection = chgRange;

doc. Copy();

Prepare for the changes doc and paste there the modified section.

var firstChgPgf = changesDoc.MainFlowInDoc.FirstTextFrameInFlow.LastPgf;

var changesTloc = new TextLoc (firstChgPgf, Constants.FV_OBJ_END_OFFSET);

var changesTRange = new TextRange (changesTloc, changesTloc);

changesDoc.TextSelection = changesTRange;

changesDoc.Paste ();

To go at the end of the file again (I think)

var lastPgf = changesDoc.MainFlowInDoc.FirstTextFrameInFlow.LastPgf;

var dividerPgf = changesDoc.NewSeriesPgf (lastPgf);

var TLoc = new TextLoc (dividerPgf, 0);

changesDoc.AddText (TLoc, '_');

}

Hi Mark,

The problem is that the dough does not occur when you think. The dividing line is added at the end of the file, but are not your actions of dough. Actually, I think that maybe a little random where pasta is produced, because this line:

var changesTloc = new TextLoc (firstChgPgf, Constants.FV_OBJ_END_OFFSET);

.. .is does not create a valid text location. You can check this by abandoning the service after:

changesDoc.TextSelection = changesTRange;

.. and look at where's the insertion point. It will probably be everywhere where you left it last, because the call is not valid. I can't tell you exactly why, except that it has something to do with the fact that you are using the last paragraph in the stream. There is something weird to try to define a range of full-paragraph text with the last paragraph. I'm sure it's related to how the last TFP in a stream does not show a mark of FMP, but beyond that, I don't know how to do what you're trying to do with the last paragraph.

Having no knowledge of how do it right, any time I need to do this, I create a paragraph "dummy" at the end of the flow to fill that space strange 'last FMP", then do the work around it. In the end, I just want to remove fake TFP. I don't know if it's a good idea or not, but it's the only way I ever get it to work and it sorts the mirror how you could do this manually in the GUI.

With this, I modified your script as follows, and it seems to work better. Note that I also modified the logic of how to find the last paragraph of the flow by writing a separate function. Your call to the 'FirstTextFrameInFlow' is OK, unless your doc begins to span several pages and/or begins with several empty pages. The function I wrote ensures that you really the last TFP in the stream.

I hope this helps.

Russ

function copyPasteChanges (doc, chgRange) {}

Select the section with changebar and copy it.

doc. TextSelection = chgRange;

doc. Copy();

Prepare for the changes doc and paste there the modified section.

var lastPgf = getLastPgf (changesDoc);

var dummyPgf = changesDoc.NewSeriesPgf (lastPgf);

var changesTloc = new TextLoc (dummyPgf, 0);

var changesTRange = new TextRange (changesTloc, changesTloc);

changesDoc.TextSelection = changesTRange;

changesDoc.Paste ();

To go at the end of the file again (I think)

Don't forget that last TFP is now fake TFP

lastPgf = getLastPgf (changesDoc);

var dividerPgf = changesDoc.NewSeriesPgf (lastPgf.PrevPgfInFlow);

var TLoc = new TextLoc (dividerPgf, 0);

changesDoc.AddText (TLoc, '_');

dummyPgf.Delete ();

}

function getLastPgf (doc)

{

textFrame var is doc. MainFlowInDoc.LastTextFrameInFlow;

var lastPgf = textFrame.LastPgf;

While (! lastPgf.ObjectValid () & textFrame.ObjectValid ())

{

textFrame = textFrame.PrevTextFrameInFlow;

lastPgf = textFrame.LastPgf;

}

Return lastPgf;

}

Tags: Adobe FrameMaker

Similar Questions

Maybe you are looking for

  • AT200 - problems of network connection to day ics

    I tried several times to update to ICS, but I can't download the software package! When I try this at home, I get about one-fifth of the full download before he says "could not download the software.Please check your network connection. I tried to do

  • Need drivers and manual for Satellite Pro 4360

    Hellopower led flashes after passage and the laptop does not start.Who knows where to find manual for Satellite Pro 4360? and where you can find drivers for windows 2000? TX, michtec

  • m1070n media center power problem

    I am running XP Pro on an HP m1070n media center & is no longer powers upward. I checked the power supply & it tests OK. I noticed that when I plug the cable of 12 volt 4-pin on the motherboard that the power supply light turns off and stays off. If

  • Windows 1.0 mouse problem

    Hi, I have Windows 1.0 running on 5.0 BACK in Virtualbox. but my mouse does not work, I think it's because the new usb mouse are not supported by the old software. But if anyone can tell me how to run my keyboard, or solve the problem of mouse that w

  • Pavilion P251NQ: Is Windows 8 supported on the Pavilion p251nq?

    Hi, guys! The portable newly purchased came with Free DOS. I have an old Windows 8 install DVD that I intend to use, but check this site I see there are only drivers for WIndows 8.1. My question is: should I go and install Win 8, hoping that the syst