Logical Functions

Functions included in this section are listed below. Click a link to jump to that function.

Logical Values
Logical Operators

BETWEEN( ) Function

DELETED( ) Function

EMPTY( ) Function

IIF( ) Function

INLIST( ) Function

NVL( ) Function

SEEK( ) Function

Logical Values:

Logical Operators

BETWEEN( ) Function

Purpose Determines if the value of an expression lies between the values of two other expressions of the same date type.
Syntax BETWEEN(<expr1>, <expr2>, <expr3>)
Returns Logical (.T., .F., 1 (true) 0 (false)
Parameter <expr1>, <expr2>, <expr3>

True (.T.) is returned if the value of <expr1> is greater than or equal to the value of <expr2> and less than or equal to the value of <expr3>; otherwise, false (.F.) is returned.

Remarks BETWEEN( ) returns a value of true (.T.) if the value of a character, numeric or date expression lies between the values of two other expressions of the same data type.

If the value of the expression doesn't lie between the values of two other expressions, BETWEEN( ) returns false (.F.).

BETWEEN( ) returns the null value if either <exp2> or <exp3> are the null value.

Examples
BETWEEN(date,{01/01/99},{06/30/99}) Returns: True if date is 04/12/99

  

DELETED( ) Function

Purpose Returns a logical value that indicates whether the current record is marked for deletion.
Syntax DELETED([<expC> | <expN>])
Returns Logical
Parameter <expC> | <expN>
Remarks If the record is marked for deletion, a true value (.T.) is returned; otherwise, a false value (.F.) is returned.

DELETED supports optional arguments that let you return the deleted status of the current record in a non-current work area.

You can check the status of the current record in a table/.DBF open in another work area by specifying the work area number with <expN> or the table/.DBF alias with <expC>. If a table/.DBF isn't open in the work area you specify, DELETED( ) returns false.

If you omit <expC> and <expN>, the deleted status is returned for the current record in the current work area.

Examples
!DELETED() If used in extra criteria or filter, only non-deleted records would be selected.

EMPTY( ) Function

Purpose Determines whether or not an expression is empty.
Syntax EMPTY(<expr>)
Returns Logical EMPTY( ) returns true (.T.) if the expression <expr> is empty; false (.F.) if the expression isn't empty.
Parameter <expr> The expression you include can be a character, numeric, date or logical expression, or the name of a memo or general field in an open table/.DBF
Remarks EMPTY( ) returns true (.T.) when expressions of the following data types contain the indicated data:

Character Nulls, spaces, tabs, carriage returns or line feeds or any combination of these
Numeric 0
Date Null (i.e. CTOD(''))
Logical False (.F.)
Memo Empty (no contents)
General Empty (no OLE object)

Example
EMPTY(pr2) If pr2 is blank, it returns a false.

IIF( ) Function

Purpose Returns one of two values depending on the value of a logical expression.
Syntax IIF(<expL>, <expr1>, <expr2>)
Returns Character, Date, Logical or Numeric
Parameter <expL> The logical expression that IIF( ) evaluates is specified with <expL>.

<expr1>, <expr2> If <expL> evaluates to true (.T.), <expr1> is returned. If <expL> evaluates to false (.F.), <expr2> is returned.

Remarks This function, also known as Immediate IF, evaluates a logical expression and then returns one of two expressions. If the logical expression evaluates to a true value (.T.), IIF( ) returns the first expression. If the logical expression evaluates to a false value (.F.), IIF( ) returns the second expression.
Examples This example uses IIF( ) to check if the PR field is empty. If it is empty, "No producer " is displayed; otherwise, the Producer's 3 char code is displayed.

INLIST( ) Function

Purpose Determines whether or not an expression matches one in a series of expressions of the same data type.
Syntax INLIST(<expr1>, <expr2>[, <expr3> ...])
Returns Logical
Parameter <expr1>  The expression searched for in the set of expressions is specified with <expr1>.

<expr2>[, <expr3> ... ] Specify the set of expressions to search with <expr2>, <expr3> and so on. You must include at least one expression (<expr2>), and can include up to 24 expressions.

All the expressions in the list must be of the same data type (character, numeric, logical or date).

Remarks INLIST( ) searches for an expression in a set of expressions. INLIST( ) returns true (.T.) if it finds the expression in the set of expressions. If it doesn't find the expression in the set of expressions, INLIST( ) returns false (.F.).
Examples
IIF(INLIST(trans,’NEW’,’NIS’),’New Policy’,’Renewed’) If trans is either NEW or NIS, it returns ‘New Policy’ otherwise it returns ‘Renewed’.

NVL( ) Function

Purpose Returns a non-null value from two expressions.
Syntax NVL(<expr1>, <expr2>)
Returns Character, Date, DateTime, Numeric, Currency, Logical, or the null value
Parameter <expr1>,< expr2> NVL( ) returns <expr2> if <expr1> evaluates to a null value. NVL( ) returns <expr1> if <expr1> is not a null value. <expr1> and <expr2> may be any data type. NVL( ) returns .NULL. if both <expr1> and <expr2> both evaluate to the null value.
Remarks Use NVL( ) to remove null values from calculations or operations where null values are not supported or are not relevant.
Examples
NVL(.T., desc) Returns: .T.
NVL(pr1, pr2) If pr1 is null, it returns pr2 otherwise it returns pr1.

SEEK( ) Function

This function is not used in TAM.