Highlighted

FM 2019: Find and Replace Text Inside of Marker

Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hello -- I have a giant publication that contains hundreds of hypertext markers that contain codes that change yearly. FM can find based on the code, but the change option pastes the new code into the body instead of at the end of the hyperlink as it should.

I can make the change after exporting to html5, but isn't there a way I can efficiently do it in the source files?

Thanks in advance ...

Mike

Hi Mike,

You can find lots of samples for beginners here:

FrameMaker ExtendScript Samples - West Street Consulting

To answer your immediate question, you should be able to just:

1 - Select File > Script > New Script.

2 - In the ExtendScript toolkit editor, you should get a blank script file. Paste the script I gave you into that file.

3 - Because the code I gave you is encapsulated in a function, you'll need to add the following line to the beginning of the file to execute it:

searchAndReplaceMarkerText();

4 - Make sure the desired file is open in FrameMaker and click the Run button in the editor.

Note that you need to have FM2019 fully updated for this to work. There was a bug in the initial release version where the File > Script > New Script command did nothing.

Hope this gets you somewhere.

Russ

Views

441

Likes

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

FM 2019: Find and Replace Text Inside of Marker

Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hello -- I have a giant publication that contains hundreds of hypertext markers that contain codes that change yearly. FM can find based on the code, but the change option pastes the new code into the body instead of at the end of the hyperlink as it should.

I can make the change after exporting to html5, but isn't there a way I can efficiently do it in the source files?

Thanks in advance ...

Mike

Hi Mike,

You can find lots of samples for beginners here:

FrameMaker ExtendScript Samples - West Street Consulting

To answer your immediate question, you should be able to just:

1 - Select File > Script > New Script.

2 - In the ExtendScript toolkit editor, you should get a blank script file. Paste the script I gave you into that file.

3 - Because the code I gave you is encapsulated in a function, you'll need to add the following line to the beginning of the file to execute it:

searchAndReplaceMarkerText();

4 - Make sure the desired file is open in FrameMaker and click the Run button in the editor.

Note that you need to have FM2019 fully updated for this to work. There was a bug in the initial release version where the File > Script > New Script command did nothing.

Hope this gets you somewhere.

Russ

Views

442

Likes

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
Apr 24, 2019 0
Adobe Community Professional ,
Apr 24, 2019

Copy link to clipboard

Copied

To the best of my knowledge, FrameMaker does not provide S&R capabilities within any of the various markers. However, you might want to get in touch with Silicon Prairie Software. The IndexTools Pro plugin is used to create index markers based on text included in a document that has a special format and condition; it can also expand existing Index markers into that text. It might be adaptable to hypertext markers, and Steve does do custom work. I don't know what his rates are, though.

Likes

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
Reply
Loading...
Apr 24, 2019 3
Adobe Community Professional ,
Apr 25, 2019

Copy link to clipboard

Copied

Hi,

Yes, good tip.

Silicon Prairie`s Index Tools Pro plugin inserts the marker text as regular text. Therefore you can work with variables, search and replace text and apply conditions.

You can test the plugins before you buy.

https://www.siliconprairiesoftware.com/Products.html

Best regards

Winfried

Likes

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
Reply
Loading...
Apr 25, 2019 0
Mentor ,
Apr 25, 2019

Copy link to clipboard

Copied

Hi Mike,

This is a perfect job for ExtendScript. And it would not require much code. The following simple script function will search all markers in the active document and replace the FindMe value with the ReplaceMe value. It is case-sensitive but it doesn't need to be.

function searchAndReplaceMarkerText()

{

    var searchString = "FindMe";

    var replaceString = "ReplaceMe";

    var markersAdjusted = 0;

   

    var doc = app.ActiveDoc;

    if(!doc.ObjectValid())

    {

        alert("No active document. Cannot continue");

        return;

    }

    var marker = doc.FirstMarkerInDoc;

    while(marker.ObjectValid())

    {

        var text = marker.MarkerText;

        var index = text.indexOf(searchString);

        if(index > -1)

        {

            text = text.substring(0, index) +

                replaceString +

                text.substring(index + searchString.length, text.length);

               

            marker.MarkerText = text;

            markersAdjusted++;

        }

       

        marker = marker.NextMarkerInDoc;       

     }

    alert("Operation complete. " + markersAdjusted + " markers adjusted.");

}

Hope this helps.

Russ

Likes

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
Reply
Loading...
Apr 25, 2019 4
Community Beginner ,
Apr 25, 2019

Copy link to clipboard

Copied

This is fantastic Russ, thanks! I do confess that I'm unfamilar with extendscript, but can work with java, which it looks identical to. Can you please let me know where I execute this from or point me to a good tutorial?

Much obliged! 

-Mike

Likes

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
Reply
Loading...
Apr 25, 2019 0
Mentor ,
Apr 25, 2019

Copy link to clipboard

Copied

Hi Mike,

You can find lots of samples for beginners here:

FrameMaker ExtendScript Samples - West Street Consulting

To answer your immediate question, you should be able to just:

1 - Select File > Script > New Script.

2 - In the ExtendScript toolkit editor, you should get a blank script file. Paste the script I gave you into that file.

3 - Because the code I gave you is encapsulated in a function, you'll need to add the following line to the beginning of the file to execute it:

searchAndReplaceMarkerText();

4 - Make sure the desired file is open in FrameMaker and click the Run button in the editor.

Note that you need to have FM2019 fully updated for this to work. There was a bug in the initial release version where the File > Script > New Script command did nothing.

Hope this gets you somewhere.

Russ

Likes

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
Reply
Loading...
Apr 25, 2019 3
Community Beginner ,
Apr 25, 2019

Copy link to clipboard

Copied

You, sir, are the MAN!

Worked perfectly. FM19 stil didn't open a new script at the command even after updating, but I just installed the extend script toolkit, linked it to FM19 and ran it from there. Thanks so much for introducing me to a whole new world ... I'm going to have some fun with this!

- Mike

Likes

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
Reply
Loading...
Apr 25, 2019 0
Mentor ,
Apr 26, 2019

Copy link to clipboard

Copied

Mike, in my opinion, the ability to customize FrameMaker is one of its strongest differentiators in the marketplace. That along with its structured interface. So many people whine and complain about how "it doesn't do this" or "it doesn't do that" when in reality it can do whatever you want it to. Then when you suggest a little bit of scripting, they make a rock-solid commitment against learning anything new. It's an odd thing. But that is just a mini rant to buffer my main point, which is that I'm glad you were willing to give it a chance. ExtendScript really is not that hard and you are missing out on so much without it. Indeed it is fun... I hope that you dive in. Stop by here if you have questions, because the documentation is imperfect and even experienced developers sometimes have to ask for help.

Russ

Likes

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
Reply
Loading...
Apr 26, 2019 2
Adobe Community Professional ,
Apr 24, 2019

Copy link to clipboard

Copied

As another thought, you MIGHT be able to do this by saving the files out to MIF, editing the link in the MIF, and then converting back to Frame.

Likes

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
Reply
Loading...
Apr 24, 2019 0