.ig >>
<STYLE TYPE="text/css">
<!--
        A:link{text-decoration:none}
        A:visited{text-decoration:none}
        A:active{text-decoration:none}
        OL,UL,P,BODY,TD,TR,TH,FORM { font-family: arial,helvetica,sans-serif;; font-size:small; color: #333333; }

        H1 { font-size: x-large; font-family: arial,helvetica,sans-serif; }
        H2 { font-size: large; font-family: arial,helvetica,sans-serif; }
        H3 { font-size: medium; font-family: arial,helvetica,sans-serif; }
        H4 { font-size: small; font-family: arial,helvetica,sans-serif; }
-->
</STYLE>
<title>quisp: conditional expressions</title>
<body bgcolor=99cc99 vlink=0000FF>
<br>
<br>
<center>
<table cellpadding=2 bgcolor=FFFFFF width=550 ><tr>
<td align=right><a href="quisp_home.html">
<img src="img/quisp2.gif" border=0><br><small>quick server pages</a> &nbsp; &nbsp; </td></tr>
<td>
.>>

.TH conditional expressions TDH "07-APR-2004   TDH scg@jax.org" 

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

.ig >>
<br><br><br>
.>>

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

.ig >>
<br><br><br>
.>>

.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

.ig >>
<br><br><br>
.>>

.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
.ig >>
<br><br><br>
.>>
.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 
.ig >>
<a href="commalist.html">
.>>
\0comma-delimited list
.ig >>
</a>
.>>
.br
.ig >>
</td></tr><tr><td>
.>>
\fB!IN\fR
.ig >>
</td><td>
.>>
opposite of IN.  Alternative usage: NOTIN
.br
.ig >>
</td></tr><tr><td>
.>>
\fBINLIKE\fR
.ig >>
</td><td>
.>>
similar to IN but 
.ig >>
<a href="commalist.html">
.>>
\0comma-delimited list
.ig >>
</a>
.>>
members may contain wild cards.
.br
.ig >>
</td></tr><tr><td>
.>>
\fB!INLIKE\fR
.ig >>
</td><td>
.>>
opposite of INLIKE.  Alternate usage: NOTINLIKE
.br
.ig >>
</td></tr><tr><td>
.>>
\fBINRANGE\fR
.ig >>
</td><td>
.>>
true if field content is within a numeric range, expressed as a
.ig >>
<a href="commalist.html">
.>>
\0comma-delimited list
.ig >>
</a>
.>>
(no embedded whitespace).
.br
.ig >>
</td></tr><tr><td>
.>>
\fBOUTRANGE\fR
.ig >>
</td><td>
.>>
true if field content is outside a numeric range, expressed as a
.ig >>
<a href="commalist.html">
.>>
\0comma-delimited list
.ig >>
</a>
.>>
(no embedded whitespace).
.br
.ig >>
</td></tr><tr><td>
.>>
\fBCONTAINS\fR
.ig >>
</td><td>
.>>
multiword comparisons (more below).
.ig >>
</td></tr></table>
.>>

.ig >>
<br><br><br>
.>>

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


.ig >>
<br><br><br>
.>>

.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>
.>>
.ig >>
<br><br><br>
.>>

.ig >>
<br><br><br>
.>>

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


.ig >>
<br><br><br>
.>>

.SH CONTAINS
The \fCCONTAINS\fR 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.

.ig >>
<br><br><br>
.>>

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

.ig >>
<br>
<br>
</td></tr>
<td align=right>
<a href="quisp_home.html">
<img src="img/quisp2.gif" border=0></a><br>
<small>quick server pages &nbsp; &nbsp;<br>
<a href="Copyright.html">Copyright Steve Grubb</a> &nbsp; &nbsp;
</td></tr>
</table>
.>>
