conditional expressions


Welcome     Gallery     Handbook


Manual page for conditional_expressions(PL)

DESCRIPTION

Ploticus uses conditional expressions in script #if statements, and in data select attributes (for example, proc bars has a select attribute).

EXAMPLES

Some examples of conditional expressions as used with the #if operator...

#if @MODE = red

#if @MODE in red,green,blue

#if @COUNT > 2

#if @COUNT > 2 || @MODE = A

#if @COUNT > 2 && @MODE = A

Some examples of conditional expressions as used with the select attribute. Note that data field references have a preceding double at-sign (@@):

select: all (select all records)

select: @@4 = red (select all records where field 4 is equal to red)

select: @@color = red (select all records where the field named 'color' is equal to red. This works only when fieldnames have been defined in proc getdata.)

select: @@4 in A,B,C ( '' where field 4 is one of A, B, or C)

select: $inrange(@@2,X) = 1 ( '' where field 2 is in plottable range of X axis)

select: $inrange(@@1,X,-5,5) = 1 ( '' where field 1 is in the range of -5 to +5 on the X axis)

A gallery example having a conditional select is timeline1a

DESCRIPTION

As can be seen in the above examples, operands may be numeric or alphanumeric. Operands and operators are delimited by white space. Operands may be literal, a @variable , or a $function . In select attributes operands may also be dfields (a preceding at-sign (@) is used). No quotes are used; an embedded space within an alphanumeric may be represented using an underscore (_). To test for a zero length string use the $strlen function, e.g. $strlen(@VAL) < 1

THE 'INRANGE' FUNCTION

A common operation in select attributes is to select only data that are within plottable range. A function called $inrange is available to do that. For example:
	select:  $inrange(@@5,Y) = 1
would select only data records where field 5 is within plottable range with respect to the Y axis.

A number of other functions are also available.

LOGICAL OPERATORS

Available operators are:
= 	Equal to.  Case sensitive for strings. 
!=	Not equal to. 
> 	Greater than. 
>= 	Greater than or equal to. 
<  	Less than. 
<= 	Less than or equal to. 

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.

List operators: A list is a comma-delimited series of values with no embedded spaces, such as x,y,z or red,green,yellow. In all of these, the list must be given on the right side of the operator.

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 presidence, AND always has higher presidnece than OR (ANDs are evaluated after all ORs are evaluated).

MORE EXAMPLES

More examples of conditional expressions:

Example: @SCORE > 70 && @SCORE <= 80

Example: $strlen(@INPUT) = 0

Example: @VAR in A,F,R,none

Example: @VAR like Gr*

Example: @VAR inlike Gr*,Gu*,Gy*

Example: @VAR in 02,08 || @STATUS = u

LIMITATIONS AND BUGS

Embedded spaces within character string operands are not allowed; underscore (_) is often used to represent spaces.

Embedded commas within character string operands may cause problems if operand is used on the right side of a list operator, or within a function call.

Operands which happen to be &&, ||, or not: will be misinterpreted.

Operands beginning with $ followed by an alpha character will be misinterpreted as function calls.

There is no way to represent a 0 length string in a conditional. Instead, $strlen() should be used to test for 0 length strings.

Evaluation order when && and || are both found in an expression cannot be controlled by applying parentheses (see LOGICAL CONNECTORS section).


data display engine  
Copyright Steve Grubb


Markup created by unroff 1.0,    June 26, 2001.