Compare operations

Pulsar supports compare operations such as <,>,== and others but the syntax is a bit different than in other languages. Instead of operators, you use functions:

{[ if @is.gt(var1, var2) ]}
  Executes when var1 > var2
{[/]}

The following compare functions are available:

is.gt

is.gt results to true when argument 1 is greater than argument 2.

{[ if @is.gt(arg1, arg2) ]}
  Executes when arg1 > arg2
{[/]}

is.lt

is.gt results to true when argument 1 is less than argument 2.

{[ if @is.lt(arg1, arg2) ]}
  Executes when arg1 < arg2
{[/]}

is.nil

is.nil results to true when argument 1 is nil. Note that value ofnil is not the same as not defined! For example, retrieving detail about a specific screen that didn't exist produces nil, however not defining the variable is completely different

{[ if @is.nil(arg1) ]}
  Executes when arg1 is nil
{[/]}

is.defined

is.defined results to true when argument 1 is undefined. Undefined variables were never defined in the current context (or in global context). Note that defined variables which are nil will result in false.

{[ if @is.defined(arg1) ]}
  Executes when arg1 was defined in current scope
{[/]}

is.equals

is.equals results to true when both arguments are equal. Note that this means they have the same value (but don't necessarily have to have the same data type, such as Double and Integer defined number 1).

{[ if @is.equals(myNumber, 1) ]}
  Executes when myNumber == 1
{[/]}

iif

Ternary function iif can be used to evaluate a boolean statement and then use one of two declared results:

{[ var myVariable @iif(@is.equals(textVariable, "Test"), 1, 2) ]}

In the example above, the statement (@is.equals(textVariable, "Test")) is evaluated. When true, myVariable is defined as 1, while when resulting to false, myVariable is defined as 2.

Last updated