EMPTY( ) Function

Determines whether an expression evaluates to empty.

EMPTY(eExpression)

Parameters

  • eExpression
    Specifies the expression that EMPTY( ) evaluates. You can specify an expression with Character, Numeric, Date, Varbinary, Blob, or Logical type, or the name of a Memo or General field in an open table.

Return Value

Logical. EMPTY( ) returns True (.T.) if the expression eExpression evaluates to empty; otherwise, EMPTY( ) returns False (.F.).

When expression types evaluate to the values in the following table, EMPTY( ) returns True (.T.).

Expression type

Evaluates to

Blob

Empty (0h) or contains only zero bytes, for example, 0h00, 0h000000, and so on

Character

Empty string, spaces, tabs, carriage returns, linefeeds, or any combination of these

Currency

0

Date

Empty, for example, CTOD('')

DateTime

Empty, for example, CTOT('')

Double

0

Float

0

General

Empty (no OLE object)

Integer

0

Logical

False (.F.)

Memo

Empty (no contents)

Numeric

0

Varbinary

Empty (0h) or contains only zero bytes, for example, 0h00, 0h000000, and so on

Remarks

You cannot use EMPTY( ) to determine whether 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')

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 TAGCOUNT( )
   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

Reference

LEN( ) Function

TYPE( ) Function

ISNULL( ) Function

Other Resources

Functions