Doc.Composer SetVar/Var enhancement

Doc.Composer is a powerful tool for generating various kinds of documents.

I tried making some documents contain statistical tables by it recently. After digging some references (Writer’s guide, DCTL XML Schema, etc.), I noticed that Doc.Composer or DCTL has less function about doing math.

A workaround is using <Text> tag to insert WORD field code, but it has some limitations. 1) It’s only for WORD. 2) <Text> tag cannot insert with property value or nested field code. 3) For getting field code calculation result, you must do F9 in WORD manually. 4) Field code calculation result also be affected with some misbehavior comes from WORD.

My suggestion is adding some basic math functions in DCTL. Such improvement like adding new attributes “operator” and “value” at <SetVar> tag. With these new attributes <SetVar> tag could do operator “add”, “substract”, “multiply”, “divide” at current variable with constant or property value and update result back to the variable. Support others operator like unary operation (“abs”, “sqrt”, etc.), logical operation (“not”, “or”, “and”, “xor”) and <Var> tag numeric format (digit padding, grouping, etc.) function would be better.

e.g.

<!-- assume property "multiplicity" in current context and equals "3" -->

<SetVar name="a" value="0"/>

<SetVar name="a" operator="add" value="2"/>

<SetVar name="a" operator="multiply" property="multiplicity"/>

<!-- if property or constant cannot be converted to a number just skip it -->

<SetVar name="a" operator="add" value="text"/>

<Var name="a"/>

output:

6

Hi Q-field,

Thank you for your suggestion. I am going to forward it to our team for further feasibility studies. When there is any news, I will let you know.

Best regards,
Jick Yeung