共用方式為


INLIST( ) Function

Determines whether an expression matches another expression in a set of expressions.

INLIST(eExpression1, eExpression2 [, eExpression3 ...])

Return Values

Logical or null value

Parameters

  • eExpression1
    Specifies the expression INLIST( ) searches for in the set of expressions.

  • eExpression2 [, eExpression3 ...]
    Specifies the set of expressions to search. You must include at least one expression (eExpression2), and can include up to 24 expressions (eExpression2, eExpression3, and so on).

    All the expressions in the set of expressions must be of the same data type.

Remarks

INLIST( ) returns true (.T.) if it finds the expression in the set of expressions; otherwise INLIST( ) returns false (.F.). The null value is returned if eExpression1 is the null value. The null value is also returned if eExpression1 is not the null value, eExpression1 does not match another expression, and at least one of the other expressions is the null value.

Example

In this example, INLIST( ) determines the quarter of the year for the current month. The current month is stored to the variable gcMonth. Each CASE statement uses INLIST( ) to determine whether the contents of gcMonth can be found in a list of month names. The name of the quarter returned is stored to the variable gcReporTitle.

SET TALK ON
STORE CMONTH(DATE( )) TO gcMonth
DO CASE
   CASE INLIST(gcMonth,'January','February','March')
      STORE 'First Quarter' TO gcReporTitle
   CASE INLIST(gcMonth,'April','May','June')
      STORE 'Second Quarter' TO gcReporTitle
   CASE INLIST(gcMonth,'July','August','September')
      STORE 'Third Quarter' TO gcReporTitle
   OTHERWISE
      STORE 'Fourth Quarter' TO gcReporTitle
ENDCASE
WAIT WINDOW gcReporTitle

See Also

BETWEEN( ) | CASE Statements | DO CASE ... ENDCASE Command | AT( ) | ATLINE( ) | RAT( ) | RATLINE( ) | $ Operator | OCCURS( )