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 )

  • http://www.idtp.eu Wim Hooghwinkel

    Hi,

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

  • bharatp

    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

  • http://mikewickham.com Mike Wickham

    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.

    • Bharat Prakash

      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…”,”")

      • http://mikewickham.com Mike Wickham

        That seems to have fixed it. Thanks!

  • Roman

    Hi,

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

    • Anh Gauthier

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

      • Bharat Prakash

        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

        • Anh Gauthier

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

          • Bharat Prakash

            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

  • Pingback: ExtendScript der Woche: »Suchen/Ändern von Querverweisformaten, Textbedingungen, Variablen«« – FrameMaker-Automation mit FrameScript & ExtendScript

  • Roman

    Hi Bharat,

    Could you please share the fix with others?

    Kind regards,
    Roman

    • bharatp

      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

  • Mushhood Zaheer

    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!

  • Categories

  • Archives

  • Authors

  • Useful Links

  • Recent Comments

    • Gyanesh Talwar: Hi, Thanks for your comment. Are you alluding that I should include a snapshot of the FrameMaker file...
    • DDuane: When attempting to use the script based on the provided instructions, it fails with a script alerted that...
    • Holly: Excellent explanation! But, how do I restart a list that is added to Robohelp by linking a FrameMaker file?
    • Jenny Hecker: Hi, we are on RH9. I copied the fixed files for RH9 to our output folder on our server, which is...
    • mary: I also have this problem and would like to know how to fix it. Thank you!