#set TITLE = "conditional expressions"
#include top

.SH Conditional expressions
The \fC#if\fR, \fC#elseif\fR, and \fC#while\fR commands involve conditional expressions.
Variables, constants, and function return values can be compared.

#include space

.SH 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.

#include space

.SH Examples
.IP
\fC#if @lastname = "Jones"\fR
.IP
\fC#if @lastname like "J*"\fR
.IP
\fC#if @balance < 0.0 and @status = "A"\fR
.IP
\fC#while $sqlrow() = 0 \fR
.IP
\fC#if $sqlrowcount() > 0\fR
.IP
\fC#if @status != null\fR
.IP
\fC#if @color in "red,green,blue"\fR
.IP
\fC#if @name inlike "alb*,cran*,dela*"\fR
.IP
\fC#if @zscore inrange -0.1,0.1\fR
.IP
\fC#if @zscore outrange -2.5,2.5\fR
.IP
\fC#if @authorlist contains "smith"\fR

#include space

.SH 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:
.IP
.nf
\fB= \fR        Equal to.  Case sensitive. (alt: \fB==\fR or IS)
\fB!=\fR        Not equal to (alt: \fB<>\fR or ISNOT)
\fB> \fR        Greater than.
\fB>=\fR        Greater than or equal to.
\fB< \fR        Less than.
\fB<=\fR        Less than or equal to.
\fBLIKE\fR      Wild card match.  Case insensitive.
\fB!LIKE\fR     Not a wild card match (alt: NOTLIKE)
.fi
#include space
.LP
QUISP also provides the following operators (see also the examples above):
.IP
.ig >>
<table cellpadding=2 border=1><tr><td>
.>>
\fBIN\fR
.ig >>
</td><td>
.>>
true if field content is a member of a 
#set FILE = "commalist.html"
#set TAG = "comma-delimited list"
#include link
.br
#include tabnewrow
\fB!IN\fR
#include tabmidrow
opposite of IN.  Alternative usage: NOTIN
.br
#include tabnewrow
\fBINLIKE\fR
#include tabmidrow
similar to IN but 
#set FILE = "commalist.html"
#set TAG = "comma-delimited list"
#include link
members may contain wild cards.
.br
#include tabnewrow
\fB!INLIKE\fR
#include tabmidrow
opposite of INLIKE.  Alternate usage: NOTINLIKE
.br
#include tabnewrow
\fBINRANGE\fR
#include tabmidrow
true if field content is within a numeric range, expressed as a
#set FILE = "commalist.html"
#set TAG = "comma-delimited list"
#include link
(no embedded whitespace).
.br
#include tabnewrow
\fBOUTRANGE\fR
#include tabmidrow
true if field content is outside a numeric range, expressed as a
#set FILE = "commalist.html"
#set TAG = "comma-delimited list"
#include link
(no embedded whitespace).
.br
#include tabnewrow
\fBCONTAINS\fR
#include tabmidrow
multiword comparisons (more below).
.ig >>
</td></tr></table>
.>>

#include space

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


#include space

.SH Case sensitivity
The \fC=\fR and \fC!=\fR operators are case sensitive.  The other operations are case insensitive.
To do a direct case-insensitive comparison use \fCLIKE\fR instead of \fC=\fR.

.ig >>
<a name=lists></a>
.>>
#include space

#include space

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


#include space

.SH CONTAINS
The \fCCONTAINS\fR operator
allows comparisons against multiword fields or
#set FILE = "commalist.html"
#set TAG = "comma-delimited lists".  Both the left operand and the
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.

#include space

.SH Compound conditionals, and precedence
A compound conditional is two or more conditionals that are connected
using the \fBAND\fR and/or \fBOR\fR logical connectors:
.IP
.nf
\fBAND\fR       logical AND (alternate symbol: \fB&&\fR)
\fBOR\fR        logical OR (alternate symbol: \fB||\fR)
.fi
.LP
\fBPresidence:\fR compound conditional expressions are evaluated by splitting into \fCOR\fR
terms, and then evaluating each term starting with the leftmost.
For example:
.IP
.nf
\fCwhere  A = 1  and  B = 2  OR  C = null\fR

would be split into these terms: 

1.)  A = 1 and B = 2
2.)  C = null
.fi
.LP
Unfortunately, this processing order cannot be altered by use of parentheses.  
The provided operators such as \fCIN\fR, \fCINLIKE\fR, \fCINRANGE\fR and \fCOUTRANGE\fR 
may be useful in eliminating lower-level \fCOR\fRs.
It may also be helpful to capitalize \fCOR\fRs to emphasize their precedence.

#include bottom
