Substituting 4GL variables for constants

You may want your expression to depend on a data variable rather than on a constant string, such as "HELLO".

For this, we use RTL expressions embedded in curly braces.
Note: We are now mixing two languages. The content within the braces is RTL, the content outside the braces is a PXML expression.

The rules for embedding RTL in PXML are:

  • wherever a numeric constant is allowed in PXML, you can insert an RTL numeric expression (enclosed in curly braces) instead.
  • wherever a string constant is allowed in PXML, you can insert an RTL string expression (enclosed in curly braces) instead.
For example, consider this expression:
max(10cm,width("HELLO"))
This PXML expression contains one numeric constant ("10") and one string constant ("HELLO"). These constants can be replaced by data variables, enclosed in curly braces:
max({orderline.orders.shipcity.trim().length()}cm,width("{orderline.orders.shipcity}")) 
Tip: It is good practice to use the trim() function to remove extra white space from a string expression.

For this expression to be legal, the variable order_line.titlewidth has to be of type Numeric, and the variable order_line.title has to be of type String.

Note: You cannot construct a dynamic expression where the function names (such as max or width) or the unit names (such as cm) are dynamic.