Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

NullDisplay, SET NULLDISPLAY, Set(“NullDisplay”)

This property and command let you determine what the user sees when a displayed value is null. The function tells you the current setting.

Usage

oObject.NullDisplay = cNullString
cNullString = oObject.NullDisplay
SET NULLDISPLAY TO [ cNullString ]
cNullString = SET("NULLDISPLAY")

By default (in VFP 3, always), nulls are displayed as .NULL.—not very informative to the average user, is it? Starting in VFP 5, you can control what’s shown. SET NULLDISPLAY is the global version—it affects all displays except those for which the NullDisplay property has been set. SET NULLDISPLAY affects all forms of output, not just controls used in forms. The NullDisplay property affects a single object.

Beware: Neither grids nor columns have their own NullDisplay property. Of course, the controls in the columns have NullDisplay, but when Sparse is .T. for a column, the control’s NullDisplay is used when the cell has focus and the SET NULLDISPLAY setting applies when the cell doesn’t have focus. This means that what you see for a given cell with a null value can change as you move in and out of the cell. Bottom line: When grids are involved, SET NULLDISPLAY and NullDisplay should be set the same (or leave NullDisplay empty to use the default value). In fact, that’s usually the case.

Use something that means “I dunno” (like “???”) for your null display string and your users will probably get it.

Example

SET NULLDISPLAY TO "???"
?.null.   && displays ???

See Also

Set Null