0

In a word file if have a field looking like:

{ = { IF "${COSTS}" = "" 0 "${COSTS}" } \# "#.0000" }

-> That gives my a Syntax Error!

However the following works fine:

{ = { IF "100" = "" 0 "100" } \# "#.0000" }

P.S: ${COSTS} is a placeholder that is replaced automatically by a software tool.

What can I do here?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
binfch
  • 31
  • 3
  • Can you verify that the {} in "${COSTS}" are 'ordinary' {} (that you can type on the keyboard, and that all the other {} are proper field code brace pairs (the ones you can insert with ctrl-F9)? Or maybe they are all field code brace pairs and the tool removes the {COSTS} fields? What does the Syntax error code actually say? –  Jul 22 '16 at 10:34

2 Answers2

0

My best guess is that the software that is replacing the code is having trouble with the spaces. Instead of putting #{COSTS} in quotes, try percent symbols? That works in batch. You should put what software your using to replace the code in your question.

creikey
  • 119
  • 9
  • Thx but changing ${COSTS} for #[COSTS] for instance does not work eather. So I tend to think it is an issue (maybe formatting) within word!? – binfch Jul 21 '16 at 08:44
0

The syntax of the IF field as described by the documentation is

{ IF Expression1 Operator Expression2 TrueText FalseText }

In your first example the field value will be the text ${COSTS}, and not a number.

The syntax of the outer formula field according to the documentation is

{ = Formula [Bookmark ] [\#Numeric Picture ] }

The important part is the one about the formula (highlight by me):

A formula is an expression that can contain any combination of numbers, bookmarks that refer to numbers, fields resulting in numbers, and the available operators and functions. The expression can refer to values in a table and values returned by functions.

In your first example, the inner field does not yield a number, hence the syntax error.

The solution will be to have the inner field return a number. Depending on where this number is coming from, this could e.g. be realized using bookmarks.

Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316