Empty()
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.
Usage |
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. |
EMPTY() behaves strangely when presented with an object reference variable. If the variable actually contains an object reference, EMPTY() generates error 11, "Function argument value, type or count is invalid," which we disagree with—if it's an object reference, it's not empty. If the variable is .NULL., EMPTY() correctly returns .F. You have to test VARTYPE(var) or TYPE('var') before checking for EMPTY() to avoid this bug. |
Example |
? EMPTY(cLastName) IF EMPTY(nUserInput) WAIT WINDOW "Enter a numeric value" ENDIF |
See Also |