Blank

Duke: And what's her history?
Viola: A blank, my lord.

—William Shakespeare, Twelfth Night

BLANK was added to FoxPro in version 2.6 as part of Microsoft's attempt to woo dBASE users. It's part of an approach that's sort of halfway to nulls.

Usage

BLANK [ FIELDS FieldList ]
      [ Scope ]
      [ FOR lForExpression ]
      [ WHILE lWhileExpression ]
      [ NOOPTIMIZE ]
      [ IN cAlias | nWorkArea ]
When records are first added to a table, fields that aren't assigned values (as with INSERT-SQL's VALUE clause) are "blank." What this really means is that, rather than containing an empty value of the field's specified type, all the fields contain spaces (CHR(32)). This is why sometimes an empty, noncharacter field shows up as totally blank in a Browse, while at other times it shows the empty value for its type (0 for numeric, .F. for logical, and so on). Because the empty string isn't a legal value for most field types, somebody wised up along the way and realized that you could test for this. That's what ISBLANK() does. Well, if you can test for it and you'd like to distinguish between this kind of empty field and the kind that contains the usual empty value for the data type, you probably want to be able to re-create that situation. Enter BLANK. It populates the specified fields (or all fields if you don't specify) with CHR(32). When you apply ISBLANK() to the BLANKed fields, it returns .T.BLANK is moderately useful for numerics and logical fields, but doesn't help at all with character or the date types, where CHR(32) is the normal empty value. Despite its limitations, there are a few places where BLANK seems useful—for example, when recycling deleted records, or for clearing several fields at a time. On the whole, though, with true nulls supported in Visual FoxPro, your best bet is to ignore BLANK and ISBLANK(). The one place we thought we might use blanks was a project in which we collected survey data. The varied answers seem to fit these new capabilities, since you can now store four states in a logical field—True, False, Blank and Null—as Yes, No, Don't Know, and Refused to Answer. However, unlike nulls, blanks do not remove themselves from calculations, still appearing as a logical false unless ISBLANK() is tested. The additional coding needed to check for this every time made it obvious that a much better solution was a single character status field.VFP 7 adds the IN clause to this command, so that you don't have to change work areas. We're glad to see it here for completeness, even though we haven't used this command in years.If you insist on using this command, you'll find information on Scope and the FOR and WHILE clauses in "Xbase Xplained." As for NOOPTIMIZE, it's generally a bad idea—see SET OPTIMIZE for all the reasons.

Example

BLANK nTotal FOR lExpired IN Summary

See Also

Empty(), IsBlank(), Set Null, Set Optimize


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .