GTL supports standard arithmetic operators along with some advanced template operators.
The following standard arithmetical and logical operators are supported, where x and y can be numbers or templates resolving to numbers:
Operator |
Description |
---|---|
%+(x,y)% |
Addition operator |
%-(x,y)% |
Subtraction operator |
%*(x,y)% |
Multiplication operator |
%/(x,y)% |
Division operator |
%&(x,y)% |
Logical bitfield and operator |
In this example, the template in the left column produces the output on the right:
Template | Results |
---|---|
Base number= %Number% Number+1= %+(Number,1)% Number-1= %-(Number,1)% Number*2= %*(Number,2)% Number/2= %/(Number,2)% Number&1= %&(Number,1)% |
Base number= 4 Number+1= 5 Number-1= 3 Number*2= 8 Number/2= 2 Number&1= 0 |
The following advanced template operators are also supported:
Operator |
Description |
---|---|
* |
Dereferencing operator - The syntax [*]+local-value [(param-list)] returns the object member defined by the evaluation of [*]+ local-value. If the given object member happens to be a template, a parameter list may be specified. Applying the star operator corresponds to a double evaluation (the * operator acts as a dereferencing operator). If a local variable is defined as: .set_value(C, Code), then %C% will return "Code" and %*C% will return the result of the evaluation of %Code%. In other words, %*C% can be thought of as %(%C%)% (the latter syntax being invalid). |
! |
Power evaluation operator - Evaluates the results of the evaluation of the variable as a template. For example, you define a comment containing a variable like %Code%. When you use the ! operator in %!Comment%, the actual value of %Code% is substituted for the variable block. Without the ! operator, the variable remains unevaluated. The ! operator may be applied any number of times. For example: %!!template% This outputs the results of the evaluation of the evaluation of the evaluation of template 'template' |
? |
The ? operator is used to test the existence of a template, a local variable, a volatile or an extended attribute. It returns "true" if the variable exists, "false" otherwise. For example, if custname is defined whereas custid is not, then the template: .set_value(foo, tt) %custname?% %custid?% outputs: true false |
+ |
The + operator is used to test if an object property is visible in the interface. For example, you could test if the Type box is displayed in the General tab of a database property sheet in a DMM, and thus that a Replication Server XEM is attached to the model. The %Database.Type+% template will output false if no XEM is attached to the model. |