This function tells you whether an item is empty—that is, devoid of content. It has two major uses: checking whether a string is totally blank without having to worry about SET EXACT
, and checking whether a variable or field is uninitialized without worrying about its type. Both of these are important enough that EMPTY()
appears frequently in our code.
lIsItEmpty = EMPTY( eExpr )
Parameter |
Value |
Meaning |
eExpr |
Character |
Check whether eExpr is composed only of spaces, tabs (CHR(09)), line feeds (CHR(10)) and carriage returns (CHR(13)). |
Any numeric type |
Check whether eExpr is 0 or blank. |
|
Logical |
Check whether eExpr is .F. |
|
Date |
Check whether eExpr contains the empty date { / / }. |
|
DateTime |
Check whether eExpr contains the empty datetime { / / : : }. |
|
Memo or General |
Check whether eExpr is completely empty—that is, has no contents at all. |
|
Screen |
Gives a "Data Type Mismatch" error. |
|
lIsItEmpty |
.T. |
eExpr is empty according to the definition for the type. |
.F. |
eExpr is not empty. |
Until nulls were added, EMPTY()
had only one confusing behavior—that a character variable or field containing only blanks (CHR(32)) is considered empty, while a memo field containing blanks is not. Nulls add to the confusion a little—EMPTY(.NULL.) returns .F. That's because nulls are special and indicate unknown data. Being null is not the same thing as being empty. Use ISNULL()
to test for .NULL.
? EMPTY(cLastName)
IF EMPTY(nUserInput)
WAIT WINDOW "Enter a numeric value"
ENDIF