How to Test for a Blank Character Variable

ID: Q102453

The information in this article applies to:

FoxBASE+

In FoxBASE+, to determine if a character field is blank, use the LEN() function in an IF statement, as follows:

   IF LEN(TRIM(x)) = 0    && where x is the blank memory variable

This function will also return the desired results when executed in all versions of FoxPro.

FoxPro versions 1.02 and Later

In FoxPro version 1.02 and later, the EMPTY() function may be used as follows:

   IF EMPTY(x)       && where x is still the blank memory variable

NOTE: The EMPTY() function is available only in FoxPro for MS-DOS versions 1.02 and later and in FoxPro for Windows.

FoxPro versions 2.6 and Later

In FoxPro version 2.6 and later, the ISBLANK() function may be used instead.

For information about the ISBLANK() function, refer to the FoxPro Help file or the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q99095
   TITLE     : ISBLANK() Function Provides Additional Null Value
               Support

Additional reference words: FoxDos FoxWin 2.x 2.00 2.10 2.50 2.50a 2.50b nothing field variable foxbase+/mac KBCategory: kbenv kbprg KBSubcategory: FxenvMemory

Last Reviewed: June 27, 1995