Removing Conditions From Text and Table Rows

It is easy to delete Condition Formats from a FrameMaker document in the interface. If you try to delete a Condition Format that is use, you will be prompted on what to do to the conditionalized text:


With ExtendScript, things aren’t so easy. If you delete a Condition Format programmatically, the conditionalized content is always deleted along with the format. There is no “option” on the Delete function to make the text unconditional. If you want to keep the text, you will have to remove the Condition Format from any text (and table rows) where it is applied.

A couple of preliminary things: First of all, you should show all of the conditions at the beginning of your code. You can store the current ShowAll setting so you can restore it later. Second, if you do want to delete the text and rows with the Condition Format, just delete the Condition Format (CondFmt):

To see how to remove Condition Formats from text, make a sample document and add two Condition Formats to it, Condition1 and Condition2. Apply both conditions to a single paragraph. Select part of the paragraph and run this code:

This will show us a PropVal object that has information about the Condition Formats (if any) that are applied to the text. Run the following code to see the properties of the PropVal object.

The propIndent value is the kind of property it is (FP_InCond), while the propVal properties has specific information about the Condition Formats that are applied. Let’s poke further down and look at the propVal properties with this code:

As you can see, the propVal property has a lot of child properties. For Condition Formats, we are interested in the osval property. Make sure your conditional text is still selected and run this code:

You should see a dialog box like this:


The osval property is an array-like list of the CondFmt objects that are applied to the text. If there is no CondFmts applied, this osval list will be empty. Because this list is similar to an array, we can loop through it to look at the individual CondFmt objects.

When you run this code, you should see the name of each CondFmt displayed in a dialog box. You can probably see what we need to do here. Assuming that we want to remove Condition2 from the text, we need to figure out how to remove the Condition2 CondFmt object from the osval list. Once we do that, we can take the modified PropVal and apply it back to the text, which will remove the unwanted Condition Format. We will explore that in Part 2.

4 thoughts on “Removing Conditions From Text and Table Rows”

  1. For us folks using FrameScript, which doesn’t seem to have a Document.GetTextPropVal() method, how would you accomplish this?

  2. Hi Russell. What document property are you trying to get? Typically, properties are easier to retrieve with FrameScript than they are with ExtendScript.

  3. Sorry, I was referring to the article’s topic of removing text conditions from tables and table rows. The situation I have is I need to append a row to an existing table *if* that table is visible (by virtue of having its text condition set to “show”). I tried examining the table’s first row’s “InCond” element to see what text conditions applied, but that element’s count (Flow.Table.FirstRowInTbl.InCond.Count) is invariably zero, even though I’m certain that a text condition applies (I can toggle show/hide and the table appears/disappears).
    If I’m understanding the reference manual, the “InCond” is supposed to be an array of integers each of which matches a condition object. So I was expecting to
    1. Find the named table
    2. Get the list of conditions applied
    3. Iterate over the condition list checking for any that are currently set to show (“CondFmtIsShown”)
    4. If #3 finds one, then proceed to update the table

  4. Addendum: I thought initially that the Table.FirstRowInTbl.CondFmtIsShown was going to make this easy. But my test document has 2 tables only one of which is shown, and the CondFmtIsShown is 1 for both tables’ first rows.

Leave a Reply

Your email address will not be published. Required fields are marked *