Back to Notenik Docs


The Notenik Knowledge Base

12.4 Merge Commands ↑

12.4.10 if command

The if command can be used to test a variable to see if it is non-blank. If the variable is non-blank, then the following lines up to the closing endif command will be subject to normal output processing. If the variable is blank, then following lines will be skipped until the closing endif command is encountered. In this case, the first and only operand would be the variable to be tested.

The single-operand mode can also be used to test for the presence of a value of false, as when testing for an include failure. In this case, a value of false will cause following lines to be skipped until a closing endif command is encountered.

The if command can also be used to test a variable to compare it to a constant (or other variable). In this case, the command would have three or more operands: the name of the variable, a logical operator, and one or more values.

In this second scenario, three operands are provided: the first value (variable or constant), a comparison operator, and the second value (variable or constant).

Any of the following comparisons may be performed, and each may be invoked with the appropriate symbols, abbreviation or words. Note that slashes are used in the following list to separate alternative representations for each operator.

  1. = / == / eq / equals
  2. > / gt / greater than
  3. >= / !< | / ge / greater than or equal to
  4. < / lt / less than
  5. <= / !> / le / less than or equal to
  6. <> / != / ne / not equal to
  7. () / [] / co / contains
  8. !() / ![] / nc / does not contain
  9. (<) / [<] / st / starts with
  10. !(<) / ![<] / ns / does not start with
  11. (>) / [>] / fi / ends with
  12. !(>) / ![>] / ng / does not end with

Note that, if both values appear to be integers, then a numeric comparison will be performed for operands 1 - 6. In all other cases, strings will be compared.


Next: 12.4.11 else command