EMPTY( ) Function – VFOX

Determines whether an expression evaluates to empty.

EMPTY(eExpression)

Parameters

eExpression
Specifies the expression that EMPTY(В ) evaluates. You can specify an expression with CharacterNumericDateVarbinaryBlob, 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.

В Copy Code
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.

В Copy Code
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