3 Replies Latest reply on Feb 1, 2012 7:00 AM by 4everJang

    Handling conditional text

    4everJang Level 3

      Hello fellow Frame automators,


      I am looking for some insight and advice how to tackle a problem with conditional text in unstructured FM. I have a bunch of documents with many conditional elements. The client has used up to 25 conditions. I am converting their documents to structured FM and want to move the conditional text into phrase elements with an attribute that specifies the condition. This makes it much easier to handle and allows better roundtripping to XML later in the project.


      So how do I get the conditional text pieces wrapped into phrase elements and set the correct attribute ?  I was looking for condition markers in the converted documernt, as the automatically generated Conversion Table does list an element M: Conditional Text. But it does not seem to use that marker at all. The conditional text is kept in the converted document. And using a simple script I walked through all the Marker objects in the document (via the list that starts with FirstMarkerInDoc) but there are no condition markers in that list either. It looks like the condition markers are a totally different kind of animal that just happens to go by the same name...


      So how do I find the conditional text ?  If I use the Find dialog, it allows me to search for conditional text, but there is an extra dialog specifying which conditions to look for. I have not even figured out how to find ANY conditional text using that dialog (as I have never used FM's built-in method for conditional text).


      How do tell the ExtendScript Find method to find me any conditional text ?  And how do I then find out which condition was set for this text ?


      Thanks for your advice and ideas



        • 1. Re: Handling conditional text
          frameexpert Level 4

          Hi Jang,


          The Condition markers only appear in the document when conditions are hidden. You will want to show all the conditions and then look for text ranges (and table rows) that have conditions applied. Working with conditions is not trivial; you have to deal with condition formats as integers, for example. Do you have my FrameScript book? There is a chapter in the book that explains working with conditions. If you don't have it, there is a link to the conditions chapter on my home page (http://www.frameexpert.com). Of course, you will have to translate my 10-year-old FrameScript code into ExtendScript, but at least it will give you more understanding of the concepts involved.


          I would avoid using "Find" to locate FrameMaker items in your scripts. There are usually better ways to programatically find what you are looking for in a document.



          • 3. Re: Handling conditional text
            4everJang Level 3

            Hello Rick,


            Thanks for the pointer. Yes, I do have your book and I found the chapter on conditional text. I will have a go at it tomorrow when my head is fresh.