Show TOC

HTMLBusiness ExpressionsLocate this document in the navigation structure

Use

HTMLBusiness expressions are similar to those used in C, C++ or Java.

From ITS 2.2, there are new rules for

  • Operator priority

  • Operator associativity

Operator Priority

Prior to ITS 2.2, operator priority rules in HTMLBusiness were not always intuitive, and differed from C, C++, or Java.

For instance, the || operator had priority over the == operator, so ITS developers had to use parentheses unnecessarily to clarify priority.

Instead of writing

`if (a==1 && b==2)`

it was necessary to write

`if ((a==1) && (b==2))`

Otherwise, the HTMLBusiness interpreter would interpret the expression as

`if (a==(1 && b)== 2)`

From ITS 2.2, operator priority has been redefined to match that used by the programming languages C, C++, and Java:

Currently, HTMLBusiness provides the following operators, listed in decreasing order of priority:

Operator

Priority

++, --

1

*, /, %

2

+, -, &

3

==, !=, >, <, >=, <=

4

&&, ||

5

If you need a different evaluation sequence, you must use parentheses. Operators with the same priority are evaluated from left to right.

Operator Associativity

Prior to ITS 2.2, operator associativity also differed from C, C++, or Java in some (but not all) cases, since terms were evaluated from right to left (rather than from left to right).

From ITS 2.2, operator associativity has been changed to evaluate from left to right, in order to achieve consistency with other programming languages.

Therefore, the expression

`8/2*4`

is now evaluated as

`(8/2)*4` (==16)

instead of

`8/(2*4)` (==1).

Expression Syntax

The syntax summarized in the table below specifies the currently allowed forms of expression:

  • Operators with identical priority are grouped and evaluated from left to right.

  • If you want to enforce a different evaluation sequence, you must use parentheses.

Nonterminal

Derivation

expression

simpleexpr [compop simpleexpr]

simpleexpr

term { addopr simpleexpr}

term

factor { mulopr factor}

factor

( ! | ++ | --) factor

( expression) |

function call |

assignment |

lvalue [++ | -- ] |

constant

function call

internalfn ( argument {, argument}) |

externalfn ( expression {, expression})

internalfn

write | writeEnc | wgateURL | archiveURL | imageURL | mimeURL | assert

mulopr

* / % &&

addopr

+ - & ||

compop

== | != | > | < | >= | <=

The following syntax conventions are observed in tables:

Notation

Description

Usage

[...]

Square brackets

Optional derivations.

{...}

Braces

Contain zero or number of repetitions of an expression.

|

Vertical line

Alternative derivatives ( OR).

(...)

Parentheses

Combine components where uniqueness is not guaranteed.

Value Types

A variable can only be a string or an integer.

Example

The following are examples of correct expressions:

vbcom-kunde

nCustomers % 10

!fExists

a > b*2+1

name != "Walt"&" "&"Whitman"

(x -y) * (a+b) & " US$"

cond1 && (cond2 || cond3) && cond4