quisp: conditional expressions

quick server pages
| Manual page for conditional(expressions)

## Conditional expressions

The `#if`, `#elseif`, and `#while` commands involve conditional expressions.`` Variables, constants, and function return values can be compared.``

## Syntax

All tokens must be separated by whitespace and must be on the same line.`` No other code may follow on the same line.`` Alphanumeric constants should be quoted, but the parser is not strict about this.``

## Examples

  `#if @lastname = "Jones"`

  `#if @lastname like "J*"`

  `#if @balance < 0.0 and @status = "A"`

  `#while $sqlrow() = 0`

  `#if $sqlrowcount() > 0`

  `#if @status != null`

  `#if @color in "red,green,blue"`

  `#if @name inlike "alb*,cran*,dela*"`

  `#if @zscore inrange -0.1,0.1`

  `#if @zscore outrange -2.5,2.5`

  `#if @authorlist contains "smith"`

## Comparison operators

QUISP supports the following comparison operators.`` Some operators have one or more alternatives that may be used if desired.`` Supported comparison operators include:

      =         Equal to.  Case sensitive. (alt: == or IS)
      !=        Not equal to (alt: <> or ISNOT)
      >         Greater than.
      >=        Greater than or equal to.
      <         Less than.
      <=        Less than or equal to.
      LIKE      Wild card match.  Case insensitive.
      !LIKE     Not a wild card match (alt: NOTLIKE)

QUISP also provides the following operators (see also the examples above):

  IN | true if field content is a member of a comma-delimited list
  !IN | opposite of IN. Alternative usage: NOTIN
  INLIKE | similar to IN but comma-delimited list members may contain wild cards.``
  !INLIKE | opposite of INLIKE. Alternate usage: NOTINLIKE
  INRANGE | true if field content is within a numeric range, expressed as a comma-delimited list (no embedded whitespace).``
  OUTRANGE | true if field content is outside a numeric range, expressed as a comma-delimited list (no embedded whitespace).``
  CONTAINS | multiword comparisons (more below).``

## Alpha vs. numeric

`=` and `!=` can be used with any data.`` `IN`, `!IN`, `INLIKE`, and `!INLIKE` can also be used with any data (numerics will be treated as strings), so `id in "20,28,35"` is valid, as is `id like "40*"`, even if `id` is always a numeric value.`` Numeric-only comparison operators are: `> >= < <= INRANGE OUTRANGE`.``

## Case sensitivity

The `=` and `!=` operators are case sensitive. The other operations are case insensitive.`` To do a direct case-insensitive comparison use `LIKE` instead of `=`.``

## Wild card characters

Wild card matching may be done using `LIKE`, `!LIKE`, `INLIKE`, and `!INLIKE`.`` Wild card characters are * which matches any number of any character, and ? which matches a single instance of any character. Matching is case-insensitive.`` Full-fledged regular expressions capability is not implemented, and use of the `*` character is limited to the following positions: `*abc`, `abc*`, `ab*cd`, and `*abc*`. `?` may be used anywhere.``

## CONTAINS

The `CONTAINS` operator allows comparisons against multiword fields or right operand are split into words (delimited by any whitespace or punctuation).`` If one or more words in the right operand is present in the left operand, the result is TRUE.`` Otherwise the result is FALSE.``

## Compound conditionals, and precedence

A compound conditional is two or more conditionals that are connected using the AND and/or OR logical connectors:

      AND       logical AND (alternate symbol: &&)
      OR        logical OR (alternate symbol: ||)

Presidence: compound conditional expressions are evaluated by splitting into `OR` terms, and then evaluating each term starting with the leftmost.`` For example:

      where  A = 1  and  B = 2  OR  C = null

      would be split into these terms:

      1.)  A = 1 and B = 2
      2.)  C = null

Unfortunately, this processing order cannot be altered by use of parentheses. The provided operators such as `IN`, `INLIKE`, `INRANGE` and `OUTRANGE` may be useful in eliminating lower-level `OR`s.`` It may also be helpful to capitalize `OR`s to emphasize their precedence.``
quick server pages
Copyright Steve Grubb

Markup created by unroff 1.0, `` `` April 07, 2004.