Skip to main content
K.Daube
Community Expert
August 5, 2019
Answered

Markers can be found, but are undefined

  • August 5, 2019
  • 1 reply
  • 918 views

Dear all,

File https://daube.ch/zz_tests/Endnotes-simulated.mif contains markers of type Cross-Ref which all can be found with Find dialogue or a corresponding script.

I wanted to replace this method by using a while loop with NextMarkerInDoc.

But after the first iteration the next marker is considered undefined (it would be the first relevant one).

What is going on here?

The output of the script (FM-15) below is this:

Type.Name: Cross-Ref

MarkerText: 39380: 1Heading: Gugus-file1

NextMarker: 1

NextMarkerText: 37202: zen-endnote: 1 Just a footnote with some local formatting.

#target framemaker

var oDoc = app.ActiveDoc;

  TestMarkers (oDoc);

function TestMarkers (oDoc) { // =======================================

var oMarker = oDoc.FirstMarkerInDoc;

  while (oMarker.ObjectValid()) {

    $.writeln("\n Type.Name: " + oMarker.MarkerTypeId.Name);

    $.writeln("MarkerText: " + oMarker.MarkerText);

    $.writeln("NextMarker: " + oMarker.NextMarkerInDoc.ObjectValid());

    $.writeln("NextMarkerText: " + oMarker.NextMarkerInDoc.MarkerText);

    oMarker = oDoc.NextMarkerInDoc;

  }

} //--- end TestMarkers 

Same effect also in FM-12.

This topic has been closed for replies.
Correct answer Ian Proudfoot

Hi Klaus,

On line 12 you have a small mistake it should be like this:

oMarker = oMarker.NextMarkerInDoc;

I hope that helps?

Ian

1 reply

Ian Proudfoot
Ian ProudfootCorrect answer
Brainiac
August 5, 2019

Hi Klaus,

On line 12 you have a small mistake it should be like this:

oMarker = oMarker.NextMarkerInDoc;

I hope that helps?

Ian

K.Daube
K.DaubeAuthor
Community Expert
August 5, 2019

Ian,

small, but powerful!