GTL Operators

GTL supports standard arithmetic and logical 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

= Assignment operator.
== and != Equal to and not equal to operators.
> and < Greater than and less than operators.
>= and <= Greater than or equal to and less than or equal to operators.
&& and || Logical AND and logical OR operators.

%+(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 - Corresponds to a double evaluation, returning a template instead of text, using the syntax:
%*template [(P1,P2...)]%
For information about template parameters, see Passing Parameters to a Template.
In the following example, a local variable is returned normally and in a dereferenced form:
.set_value(C, Code)
%C%
%*C%
Result:
Code
%Code%

!

Power evaluation operator - Evaluates the results of the evaluation of the variable as a template.

In the following example, a local variable is returned normally and in a power-evaluated form:
.set_value(C, %%MyAttribute%%)
%C%
%!C%
Result:
%MyAttribute%
Red

The ! operator may be applied any number of times. For example:

%!!t%

This outputs the results of the evaluation of the evaluation of the evaluation of template t.

?

Existence operator - Tests whether a template, local variable, or property is present, and returns false if it is not.

For example:

.set_value (myVariable, 20, new)
%myVariable?%
.unset (myVariable)
%myVariable?%

Result:

true
false

+

Visibility operator - Tests whether an object property is visible in the interface, and returns false if it is not.

For example, to test if the Type field is displayed in the General tab of a database property sheet in a DMM (meaning that a Replication Server extension file is attached to the model), enter the following:
%Database.Type+%