<html> <head> <!-- This file has been generated by unroff 1.0, 03/11/09 12:56:13. --> <!-- Do not edit! --> <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>ploticus: conditional expressions</title> <body bgcolor=D0D0EE vlink=0000FF> <br> <br> <center> <table cellpadding=2 bgcolor=FFFFFF width=550><tr> <td> <table cellpadding=2 width=550><tr> <td><br><h2>Conditional expressions</h2></td> <td align=right> <small> <a href="../doc/welcome.html"><img src="../doc/ploticus.gif" border=0></a><br> Version 2.41 Mar2009 <td></tr></table> </td></tr> <td> <br> <br> <title>Manual page for Conditional_expressions(PL)</title> </head> <body> <b>Note:</b> this page describes conditional expressions as used in ploticus <b>#if statements</b>.<tt> </tt> <a href="select.html"> select attributes </a> are slightly different and are described <a href="select.html"> here.<tt> </tt> </a> <br><br><br> <p> Conditional expressions use a simple syntax made up of operators such as <tt>=</tt> and <tt>!=</tt>, operands, and logical connectors such as <tt>&&</tt> and <tt>||</tt>. Operands may be literal numeric, alphanumeric, or text string values, @variables, @data-fields, or <a href="functions.html"> functions </a> . In <a href="scripts.html"> scripts </a> , literal string operands may be enclosed in double quotes (") (but no quotes may be used in ploticus <b>select:</b> attributes) .<tt> </tt> There is no concept of precedence in these expressions (other than left to right); parentheses cannot be used except within strings.<tt> </tt> <p> <br><br><br> <h2>Examples</h2> <p> - In a <a href="scripts.html"> script </a> , see if the value of the variable @SUM is greater than 100: <pre> #if @SUM > 100 ... #endif </pre> <p> - Another example: <pre> #if @SUM > 100 && @STATUS = s </pre> <p> - Check to see if @description has any contents: <pre> #if $len(@description) > 0 </pre> <p> - Check to see if @val is a valid number: <pre> #if $isnumber(@val) = 1 </pre> <p> - See if @C does not countain a double quote: <pre> #if @C != "\"" </pre> <p> Here's a conditional expression for finding lastname beginning with <tt>Gr</tt>, <tt>Gu</tt> or <tt>Gy</tt>: <pre> @lastname inlike Gr*,Gu*,Gy* </pre> <br><br><br> <h2>Operands</h2> Operands may be <ul> <li> @variables <li> @field numbers, e.g. @1 = first data field <li> Literal values (numbers, alphanumerics, text strings, <a href="commalist.html"> commalists </a> ) <li> <a href="functions.html"> Functions </a> </ul> <p> In <a href="scripts.html"> scripts </a> , literal alphanumeric, text string, or <a href="commalist.html"> commalist </a> operands may be enclosed in double quotes ("); no variable evaluation occurs inside quoted strings.<tt> </tt> <br><br><br> <h2>Comparison operators</h2> <dl> <dt><dd><p> <pre> <b>= </b> Equal to. This is case sensitive for strings. <b>!=</b> Not equal to. <b>> </b> Greater than. <b>>=</b> Greater than or equal to. <b>< </b> Less than. <b><=</b> Less than or equal to. </pre> <dt><dd><p> If at least one operand is non-numeric, comparison operators such as > will do an ascii value comparison.<tt> </tt> </dl> <p> <b>Wild card matching</b>: Wild card matching may be done using <b>like</b>. Wild card characters are <b>*</b> which matches any number of any character, and <b>?</b> which matches a single instance of any character. This matching is case-insensitive.<tt> </tt> <dl> <dt><dd><p> <pre> <b>like</b> Wild card match. Example: hello like h* (true) <b>!like</b> Not a wild card match. </pre> </dl> <p> <b>Commalist operators</b>: these take a <a href="commalist.html"> commalist </a> on the right side.<tt> </tt> By default, lists are delimited using commas. If this is not convenient, the list delimitation character may be changed using <a href="control"> #control listsep </a> .<tt> </tt> <dl> <dt><dd><p> <pre> <b>in</b> Member of list. Example: z in x,y,z (true) <b>!in</b> Not a member of list. (Alt: <b>ni</b>) <b>inlike</b> Same as <b>in</b> but wild card matching is used. (Wild cards may be used in list members.) <b>!inlike</b> Same as <b>!in</b> but wild card matching is used. </pre> <br><br><br> </dl> <h2>Logical connectors</h2> Individual conditional expressions may be connected together using logical AND (<b>&&</b>) or OR (<b>||</b>).<tt> </tt> An entire expression may be negated by putting <b>not:</b> at the beginning of the expression.<tt> </tt> <p> Because parentheses may not be used to establish precedence mixing AND and OR in the same expression requires care.<tt> </tt> When the expression is parsed, it is first split into OR terms, then each of the OR terms is split into AND terms.<tt> </tt> For example: <tt>A = B and C = D or E = E of F = G</tt> would evaluate to true, because it is interpreted as if it were written <tt>(a = B and C = D) or (e = e) or (f = g)</tt>.<tt> </tt> It may be best to avoid mixing AND and OR in the same expression and use multiple expressions instead.<tt> </tt> <br><br><br> <h2>Limitations and bugs</h2> <p> Because parentheses may not be used to establish precedence, the mixing of AND and OR in the same expression is problematic (see above).<tt> </tt> <br> <br> </td></tr> <td align=right> <a href="../doc/welcome.html"> <img src="../doc/ploticus.gif" border=0></a><br><small>data display engine <br> <a href="../doc/Copyright.html">Copyright Steve Grubb</a> <br> <br> <center> <img src="../gallery/all.gif"> </center> </td></tr> </table> <br> <center> <table><tr><td> Ploticus is hosted at http://ploticus.sourceforge.net</td><td> </td><td> <a href="http://sourceforge.net/projects/ploticus"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=38453&type=12" width="120" height="30" border="0" alt="Get ploticus data display engine at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </td></tr></table> </center> <p><hr> Markup created by <em>unroff</em> 1.0, <tt> </tt> <tt> </tt>March 11, 2009. </body> </html>