EMPTY( ) Function

Determines whether an expression evaluates to empty.

EMPTY(eExpression)

Return Values

Logical

Parameters

  • eExpression
    Specifies the expression that EMPTY( ) evaluates.

    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. EMPTY( ) returns true (.T.) when expressions evaluate to the following:

    Expression type Evaluates to
    Character The empty string, spaces, tabs, carriage returns, linefeeds, or any combination of these.
    Numeric 0
    Currency 0
    Float 0
    Integer 0
    Double 0
    Date Empty (e.g. CTOD(''))
    DateTime Empty (e.g. CTOT(''))
    Logical False (.F.)
    Memo Empty (no contents)
    General Empty (no OLE object)
    Picture Empty (no picture)

    EMPTY( ) cannot be used to determine if a variable object reference is empty. For example, a variable can contain an object reference for a form. If the form is closed by clicking Close from the form's pop-up menu or by issuing CLEAR WINDOWS, the variable contains the null value.

    The following program example demonstrates how to use TYPE( ) and ISNULL( ) to determine if a variable object reference is valid.

    goMyForm = CREATEOBJECT('Form')
    WAIT WINDOW IIF(TYPE('goMyForm') = 'O' AND !ISNULL(goMyForm), ;
       'goMyForm has valid object reference',;
       'goMyForm does not have valid object reference')
    

Remarks

EMPTY( ) returns true (.T.) if the expression eExpression evaluates to empty; otherwise, EMPTY( ) returns false (.F.).

Example

The following example opens the customer table in the testdata database. FOR ... ENDFOR is used to create a loop in which EMPTY( ) s used to determine if TAG( ) returns the empty string. The name of each structural index tag is displayed with its candidate status.

CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'data\testdata')
USE customer     && Open customer table

FOR nCount = 1 TO 254
   IF !EMPTY(TAG(nCount))  && Checks for empty string
   ? TAG(nCount)  && Display tag name
   ? CANDIDATE(nCount)  && Display candidate status
   ELSE
      EXIT  && Exit the loop when no more tags are found
   ENDIF
ENDFOR

See Also

LEN( ) | TYPE( ) Function | ISNULL( ) Function