How to Determine Whether a Record Is Blank or EmptyLast reviewed: September 29, 1995Article ID: Q137410 |
The information in this article applies to:
SUMMARYFoxPro supplies functions to determine if the contents of a single field is blank (with ISBLANK()) or empty (with EMPTY()). This article will show how to use these functions to create user-defined functions (UDFs) that will return True (.T.) or False (.F.) to indicate if the entire record is blank or empty. For more information about the ISBLANK() function, please see the FoxPro Help file or the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q99095 TITLE : ISBLANK() Function Provides Additional Null Value Support ARTICLE-ID: Q102453 TITLE : How to Test for a Blank Character Variable MORE INFORMATIONCreate a program/procedure file containing the following UDF:
* Function: IsBlankRec * * Parameter: <expN> | <expC> - optional * * where <expN> is the number of the work area to check if record is * blank or, where <expC> is the name of the alias to check if record is * blank * FUNCTION IsBlankRec PARAMETER lAlias PRIVATE llSeleBack, lnSeleBack, llResult, lcFieldName, I llSeleBack = .F. lnSeleBack = SELECT(0) llResult = .T. IF PARAMETERS() = 1 llSeleBack = .T. SELECT (lAlias) ENDIF FOR I = 1 TO FCOUNT() lcFieldName = FIELD(I) IF ! ISBLANK( &lcFieldName ) llResult = .F. EXIT ENDIF ENDFOR IF llSeleBack SELECT (lnSeleBack) ENDIF RETURN llResultThis function tests to see if it needs to change work areas by the number of parameters passed to the UDF. It then loops through all the fields in the current work area, testing each field with the ISBLANK() function. The first field that returns NOT BLANK causes the memory variable llResult to be set to false (.F.) and exits the For loop. If necessary, the UDF changes back to the original work area and then return the results of the search for blank fields. If all fields in the record are blank, the UDF returns True (.T.). NOTE: To test for an empty record, you may change the name of the function to IsEmptyRec and replace the following line:
IF ! ISBLANK( &lcFieldName )with:
IF ! EMPTY( &lcFieldName ) Testing the Results
|
Additional reference words: FoxWin FoxDos 2.50 2.50a 2.50b 2.60 2.60a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |