ExtendScript of the Week : Find/Change (XRef Format/Conditional Tag/Variable)

Wednesday, November 23 2011 @ 6:38 AM, By bharatp

This week in “Extend Script of the Week” initiative we will showcase an extend script which will Find/Change XRef Format,Conditional Tag,Variables on the body page of the FrameMaker document . This script demonstrates how to use Extend Script to traverse a document, find Xrefs/Conditional Tags/Variables and then change them or delete them.

Information about the Scripts :

      • The zip contains 7 scripts . ChangeFormatMenu.jsx loads the menu and calls the function to execute the work flow. ChangeConditionalFormat.jsx is used to change the conditional tag.ChangeVariable.jsx is used to change the variable.ChangeXrefFormat.jsx is used to change the format of the XRef.ChangeFormatUtils.jsx contains various utilty functions.ChangeFormatUI.jsx prepares the UI to be launched in FM and BookIterator.jsx is used to iterate over the book.
      • The script works on FM/MIF, nested books and its components as well as on the hierarchical components
      • Any XML file, dita or map which is a part of the book is left untouched
      • The script will pick up the format/variable/tag from the document or the first non generated component of book.
      • If run on a book, all unopened components will be opened silently and will be modified, saved and closed without asking. All opened components will be modified and left visible
      • User has an option to include System Variables, by default it has been excluded as it makes the list quite long.
      • User also has an option to delete the conditional tag/variable/xref format which was replaced after the changes are made.
      • At the end the user will be notified about the number of changes made in the document.

Steps to Install :

        • Download the zip file from ChangeFormat
        • Unzip the files and copy “ChangeFormatMenu.jsx” and “ChangeFormat” folder in startup folder located at “C:\Program Files\Adobe\AdobeFrameMaker10\startup”

How to use the Script?

            • Launch FrameMaker
            • Open a Book File or FM/MIF File eg : Doc1_10.fm
            • Run Change Formats from “File -> Utilities -> Change Formats…
            • This will run the script and ask you for inputs for find/change.
            • Click on the radio button to choose the object you want to change.

            • Choose the value to be changed in ‘Find’ dropdown.
            • Choose the value to be applied in ‘Replace With’ dropdown.
            • Click on Change button.

 

I hope this will prove useful to many folks and you can add extra functionality as per your requirements to these scripts to make it even more powerful

Regards,
Bharat Prakash
FrameMaker

(Resources: ChangeFormat )

COMMENTS

  • By Wim Hooghwinkel - 8:46 AM on November 23, 2011  

    Hi,

    should the script work on structured fm files? If I try that, FM freezes.

  • By bharatp - 9:53 AM on November 23, 2011  

    Hi Wim,

    Thanks for the comment. I have not come across this issue.
    Changing conditional tags in structured FM might lead to issues sometimes ,but changing Xref format/Variable should not be a problem.
    Could you send me a sample file on which you facing the issue. My email is bharatp@adobe.com.

    Thanks,
    Bharat Prakash

  • By Mike Wickham - 6:29 PM on November 28, 2011  

    I have found a bug with this script. When installed, I can no longer type a lowercase letter “u”. Removing the script returns my ability to insert the letter into text.

    • By Bharat Prakash - 6:15 AM on November 29, 2011  

      Hi Mike ,

      Thanks for pointing it out. Kindly replace the following statement in ChangeFormatMenu.jsx and it should take care of the problem.

      Original :: var NewCommand = DefineCommand(1,”Change Formats…”,”Change Formats…”)

      New :: var NewCommand = DefineCommand(1,”Change Formats…”,”Change Formats…”,””)

      • By Mike Wickham - 12:43 AM on November 30, 2011  

        That seems to have fixed it. Thanks!

  • By Roman - 3:50 PM on December 5, 2011  

    Hi,

    For some reason, it does not work for me. When I run the script, Framemaker freezes. BTW, I fixed the var NewCommand = DefineCommand.

    • By Anh Gauthier - 3:44 PM on January 31, 2012  

      Same here – FM freezes when I try to use the menu option.

      • By Bharat Prakash - 3:50 PM on January 31, 2012  

        Hi Anh,

        Thanks for using the script. Kindly send me some sample files so that i can isolate the issue.

        Thanks,
        Bharat Prakash(bharatp@adobe.com)
        FrameMaker Engineering

        • By Anh Gauthier - 2:03 AM on February 1, 2012  

          Thanks for the response. I will prep a file and email you.

          • By Bharat Prakash - 10:17 AM on February 1, 2012  

            Hi Anh,

            I have fixed the issue and mailed you the updated scripts. Kindly let me know if there are any more issue.

            Thanks,
            Bharat Prakash(bharatp@adobe.com)
            FrameMaker Engineering

  • By Roman - 8:51 AM on February 21, 2012  

    Hi Bharat,

    Could you please share the fix with others?

    Kind regards,
    Roman

    • By bharatp - 9:02 AM on February 21, 2012  

      Hi Roman,

      I have uploaded the Latest zip containing the fixes. Kindly download these files from ‘Resources’.

      Fixes:

      1) Problem handling the flow for changing para tags
      2) There was an extra check for checking system variables . This should solve of FM freezing for some folks.
      3) Previously the script did not work on hidden tags but now it does

      Thanks,
      Bharat Prakash
      FrameMaker Engineering

  • By Mushhood Zaheer - 9:16 AM on July 31, 2012  

    Hi I tried running this script as you stated above, but FM10 throws the following console error: 
    Script Error : Error Message      : null is not an objectScript, Line#   : C:Program Files (x86)AdobeAdobeFrameMaker10startupChangeFormatChangeFormatUI.jsx,  81

    This seems to point to the following line of code in ChangeFormatUI.jsx:

    CF_setType(varbl)

    Is it okay to declare varbl as:

    var varbl = new Object();

    Thanks!

  • By mickeymammoth - 10:24 PM on March 25, 2014  

    Used this on FM11 to change all uses of an xref format. But am having mixed results. If no files in the book are open, then the list if xrefs just shows one entry: TemplateName. If I open a file, it finds actual format names. But when I run the utility, it won’t find anything. Or sometimes it does find some. Every time I run it on the same book it varies. The first time, it found tons, and I thought it was done. But it missed a lot. I’m not really sure it did change anything now.

  • Categories

  • Archives

  • Authors

  • Useful Links

  • Recent Comments

    • Don Bridges: I expect privacy concerns will tamper IoT for our homes and consumers, but for business it will usher a...
    • Lois Patterson: I’m always happy to see math support, although I’m not currently using FrameMaker. I have...
    • Olga: I know it’s a really old post but I was unable to find any information online. I need to number the...
    • click: yes. http://wwwimages.adobe.com/www .adobe.com/content/dam/Adobe/e n/volume-licensing/pdfs/avl...
    • tiggyboo: I know the specs say IE 9 or greater is required – but was Server 12 developed specifically for IE or...