[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| IIF |
+---------------------------------+
IIF(<expL>, <expr1>, <expr2>)
-----------------------------------
Returns one of two expressions depending on value of logical expression.
Return value - Character, Date, Logical or Numeric
-----------------------------------
IIF() (Immediate If) returns one of two expressions depending on the
value of a logical expression. IIF() evaluates a logical expression.
If the logical expression evaluates to a logical true value (.T.), the
first expression is returned. If the logical expression evaluates to a
logical false value (.F.), IIF() returns the second expression.
. This function may be used in place of the IF ... ENDIF structure for
simple conditional expressions. This function is especially useful in
report and label expressions to conditionally specify field contents.
The IIF() function also executes considerably faster than the equivalent
IF ... ENDIF statements.
Clauses
-------
<expL>
The logical expression that IIF() evaluates is specified by <expL>.
<expr1>, <expr2>
One of the two expressions, <expr1> or <expr2>, are returned by IIF().
If <expL> evaluates true (.T.), the first expression <expr1> is
returned. If <expL> evaluates false (.F.), the second expression
<expr2> is returned.
The expressions <expr1> and <expr2> must be of character, date, logical
or numeric type. <expr1> and <expr2> do not have to be of the same
type.
+---------------------------------+
| Program Example |
+---------------------------------+
In this example, IIF() is used to check if COMMENTS field in CUSTOMER
database is empty. If it is, "No comments" is displayed on screen;
otherwise the contents of memo field is displayed.
IF USED('customer') && If database already open
SELECT customer
ELSE && if not open, find it
USE LOCFILE('customer.dbf', 'DBF', 'Where is CUSTOMER.DBF?')
ENDIF
SCAN
? IIF(EMPTY(comments), 'No comments', comments) && Empty memo field?
ENDSCAN
-----------------------------------
See Also: IF ... ENDIF
-----------------------------------
See Also:
IF ... ENDIF
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson