Output Preset Variables syntax

When I code barcodes, there is the “text” section and the “condition” section, but they appear to use different syntax for the variables. I’d like to understand this better.

For example, when I code for a barcode containing page number, page count, and collation mark value, I do something like this.

Text: ${page.nr}${document.count.pages}1
Condition: (page.nr == 1) && (document.count.pages != 1)

What is the meaning of the “$” and the braces “{}”?

the ${} construct means that anything inside the curly braces is evaluated as pure JavaScript, with the last value being returned. So for instance you could have something like:

${var current=page.nr; var total=document.count.pages; "Page "+current+" of "+total}

In reality, to obtain the same results as in the example above, you would probably just use

${"Page " + page.nr +" of " + document.count.pages}

but the example makes it clear that you can indeed use multiple statements inside the curly braces.

1 Like

Thank you, that makes perfect sense.