Skip to main content
June 6, 2014
Answered

Applying Conditional Text with SetProps()

  • June 6, 2014
  • 1 reply
  • 871 views

Hi all,

I'm using FM 11 on Windows 7.

I'm having trouble deciphering the scripting guide (http://help.adobe.com/en_US/framemaker/scripting/framemaker_10_scripting.pdf) in relation to the SetProps() function. Specifically, I haven't been able to find a good description of the TypedVal properties (p. 400). Does anyone know of a document that describes these properties and how to use them?

My current task is to apply a conditional format to a row, but I would also like to apply a condfmt to an entire table. Here is my most recent (unsuccessful) attempt:

function setRowConditional(row, condFmt)

{

    var props = row.GetProps();

    var prop = new PropVal();

    prop.propIdent.num = Constants.FP_InCond;

    prop.propVal.ival = condFmt.id;

    prop.propVal.obj = condFmt;

    props.push(prop);

    row.SetProps(props);

}

Thanks,

Trevor

This topic has been closed for replies.
Correct answer Russ Ward

Blast that Ctrl+S shortcut that sends the message, for FM users that are used to doing Ctrl+S in their sleep.

Anyway, as I was saying, here is a sample I got to work. The doc and row arguments must be valid document and row objects, and condition is the name of the condition to apply. Regarding osval again, I'm thinking that maybe this function is only reliable if the row currently has no other conditions applied.

I thought maybe just to build an array that includes the condFmt and apply it to row.InCond directly, but it kept freezing up FM. I don't know what I was doing wrong.

function applyConditionToRow(doc, row, condition)

{

    var condFmt = doc.GetNamedCondFmt(condition);

    if(!condFmt.ObjectValid()) return;

   

    var props = row.GetProps();

    var propIndex = GetPropIndex(props, Constants.FP_InCond);

   

    props[propIndex].propVal.osval[0] = condFmt; 

   

    row.SetProps(props);

}

1 reply

Legend
June 10, 2014

Hi Trevor,

Here is a version that I got to work. I'm not entirely confident that it is the best method, because it seems a little sketchy on how the osval array is managed. However, it does generally follow some other examples I have seen.

Russ WardCorrect answer
Legend
June 10, 2014

Blast that Ctrl+S shortcut that sends the message, for FM users that are used to doing Ctrl+S in their sleep.

Anyway, as I was saying, here is a sample I got to work. The doc and row arguments must be valid document and row objects, and condition is the name of the condition to apply. Regarding osval again, I'm thinking that maybe this function is only reliable if the row currently has no other conditions applied.

I thought maybe just to build an array that includes the condFmt and apply it to row.InCond directly, but it kept freezing up FM. I don't know what I was doing wrong.

function applyConditionToRow(doc, row, condition)

{

    var condFmt = doc.GetNamedCondFmt(condition);

    if(!condFmt.ObjectValid()) return;

   

    var props = row.GetProps();

    var propIndex = GetPropIndex(props, Constants.FP_InCond);

   

    props[propIndex].propVal.osval[0] = condFmt; 

   

    row.SetProps(props);

}

June 10, 2014

Thanks Russ! Your solution seems to work well for my use case.

Do you have ideas or examples you could point me to for applying a condition to an entire table? Using GetPropIndex(tbl.GetProps(), Constants.FP_InCond); seems to return -4.