Ploticus > Scripts >
Conditional expressions

Note: this page describes conditional expressions as used in ploticus #if statements. select attributes are slightly different and are described here.

Conditional expressions use a simple syntax made up of operators such as = and !=, operands, and logical connectors such as && and ||. Operands may be literal numeric, alphanumeric, or text string values, @variables, @data-fields, or functions . In scripts , literal string operands may be enclosed in double quotes (") (but no quotes may be used in ploticus select: attributes) . There is no concept of precedence in these expressions (other than left to right); parentheses cannot be used except within strings.


- In a script , see if the value of the variable @SUM is greater than 100:

	#if @SUM > 100

- Another example:

	#if @SUM > 100 && @STATUS = s

- Check to see if @description has any contents:

	#if $len(@description) > 0

- Check to see if @val is a valid number:

	#if $isnumber(@val) = 1

- See if @C does not countain a double quote:

	#if @C != "\\""

Here's a conditional expression for finding lastname beginning with Gr, Gu or Gy:

	@lastname inlike Gr*,Gu*,Gy*


Operands may be
    @field numbers, e.g. @1 = first data field
    Literal values (numbers, alphanumerics, text strings, commalists )

In scripts , literal alphanumeric, text string, or commalist operands may be enclosed in double quotes ("); no variable evaluation occurs inside quoted strings.

Comparison operators

    = 	Equal to.  This is case sensitive for strings. 
    !=	Not equal to. 
    > 	Greater than.
    >= 	Greater than or equal to. 
    <  	Less than. 
    <= 	Less than or equal to. 
    If at least one operand is non-numeric, comparison operators such as > will do an ascii value comparison.

Wild card matching: Wild card matching may be done using like. Wild card characters are * which matches any number of any character, and ? which matches a single instance of any character. This matching is case-insensitive.

    like	Wild card match.  Example: hello like h* (true)
    !like	Not a wild card match.

Commalist operators: these take a commalist on the right side. By default, lists are delimited using commas. If this is not convenient, the list delimitation character may be changed using #control listsep .

    in	Member of list.  Example: z in x,y,z (true)
    !in	Not a member of list. (Alt: ni)
    inlike 	Same as in but wild card matching is used.
    		(Wild cards may be used in list members.)
    !inlike	Same as !in but wild card matching is used.

Logical connectors

Individual conditional expressions may be connected together using logical AND (&&) or OR (||). An entire expression may be negated by putting not: at the beginning of the expression.

Because parentheses may not be used to establish precedence mixing AND and OR in the same expression requires care. When the expression is parsed, it is first split into OR terms, then each of the OR terms is split into AND terms. For example: A = B and C = D or E = E of F = G would evaluate to true, because it is interpreted as if it were written (a = B and C = D) or (e = e) or (f = g). It may be best to avoid mixing AND and OR in the same expression and use multiple expressions instead.

Limitations and bugs

Because parentheses may not be used to establish precedence, the mixing of AND and OR in the same expression is problematic (see above).


Ploticus 2.42 ... May 2013 Terms of use /