Xbasic

ISBLANK Function

Syntax

Result_Flag as L = ISBLANK(C fieldname)

Arguments

fieldnameCharacter

The name of a table field used in a form or browse. The var-> prefix can be used to test locally defined variables.

Returns

Result_FlagLogical

Returns .t. if the field is blank, otherwise .f.

Description

Returns TRUE if the field is blank.

Discussion

ISBLANK() returns .T. (TRUE) if the field identified in the Field_Name is blank; otherwise, it returns .F. (FALSE). This function works on any type of field. The function can be used is event coding for forms and browses. Note : To test for a blank string, use ISNULL().

Example 

If CUST_ID contains "C001".

? isblank("CUST_ID")
= .F.

If ADDRESS2 is empty.

? isblank("ADDRESS2")
= .T.

' if the FIELD_NAME variable contains "ADDRESS2" 
' and the ADDRESS2 field is empty.'
? isblank(FIELD_NAME) 
= .T.

If the FIELD_NAME variable contains "ADDRESS2" and the ADDRESS2 field is empty.

? isblank(FIELD_NAME)
= .T.

Assume that you want to remove incomplete records from your table. A quick way to identify these records is to choose a field that is normally be filled in (e.g., the LASTNAME field), and search for all occurrences where it is blank. The following filter expression would work:

isblank("LASTNAME")

Use this filter with the Mark records operation to delete the active records, followed by Pack to remove them from the table.

Another way to use this function is in a mailing list application. Assume that you want your label to print "Resident" on the first line if the LASTNAME field is blank. Create and place a calculated field that uses the expression:

if(isblank("LASTNAME"), "RESIDENT", trim(FIRSTNAME) + " " + LASTNAME)

Testing Locally Declared Variables 

The ISBLANK() function can also be used to test locally defined variables. The var-> prefix can be used to reference a variable. For example:

dim str as C
? isblank("var->str")
= .T.

str = "Alpha Software"
? isblank("var->str")
= .F.

dim date as D
? isblank("var->date")
= .T.

See Also