Command if

The command if is used to specify a decision or logic comparison in a POSXML application. Other commands can be used within block if, and these commands are executed if the logical expression is true.

List of operators

  • greaterthan: greater than >
  • lessthan: less than <
  • greaterthanorequalto: grater than or equal to >=
  • lessthanorequalto: less than or equal to <=
  • equalto: equal to =
  • notequalto: not equal to !

Logic operations with integer variables

Integer operations are performed the same way as in any other programming language.

Logic operations with string variables

String operations with the operators greaterthan, lessthan, greaterthanorequalto, lessthanorequalto, happen in two stages; firstly the value is converted to a float, and then the logical operation is performed.

String operations with the operators equalto and notequalto are performed the same way as in any other programming language.

Parameters

  1. variable [integer or string]
    Variable that will be used in the comparision.
  2. operator [string]
    Comparison operators: lessthan, greaterthan, equalto, notequalto, greaterthanorequalto or lessthanorequalto.
  3. value [string or integer]
    Value that will be used in the comparison.

Example


In the example above, there are three conditions:

  • 1st - compares two strings with the operator equalto which results in true as blue is equal to the value of the variable sColor
  • 2nd - compares two numbers with the operator greaterthan which results in true as 111 is not greater than the value of the variable iNumber
  • 3rd - compares two strings using the operator notequalto which results in true as Blue is different from the value of the variable sColor. POSXML considers uppercase and lowercase letters (case-sensitive)
The command waitkey awaits a click of any key to continue code execution.