Clears data from the specified fields in the current record or from all fields in the current record when issued without additional arguments.
BLANK [FIELDS FieldList] [DEFAULT [AUTOINC]] [Scope] [FOR lExpression1] [WHILE lExpression2] [NOOPTIMIZE] [IN nWorkArea | cTableAlias]
- [FIELDS FieldList]
Clears only the fields you specify with FieldList. If you omit the FIELDS clause, all fields in a record are cleared by default. Any field you specify in an unselected work area must be prefaced with the alias of the work area.
BLANK does not clear field data of a record in another related work area if the record pointer is at the end of the file in the current work area. The record pointer must be on a record in the current work area in order for BLANK to act on the fields in the related record.
- [DEFAULT [AUTOINC]]
Initializes specified fields to their default values as specified with the DEFAULT clause for tables that belong to a database and cursors. If no fields are specified, the default values of all fields in the current record are initialized. DEFAULT does not apply to free tables.
The AUTOINC keyword specifies to include all automatically incrementing fields. If you omit AUTOINC, the automatically incrementing fields are left intact with their original values.
Performing updates to automatically incrementing fields requires locking the table header. If you call the BLANK command with the DEFAULT AUTOINC clause with the table file opened in shared mode, is unlocked, and the SET MULTILOCKS command is set to OFF, Visual FoxPro generates an error.
Specifies a range of records to clear. The default scope for BLANK is the current record (NEXT 1). Only the records that fall within the range are cleared.
The scope clauses are: ALL, NEXT nRecords, RECORD nRecordNumber, and REST.
Commands that include the Scope parameter operate only on the table in the active work area.
For more information on scope clauses, see.
- FOR lExpression1
Clears field data in records for which lExpression1 evaluates to True (.T.). Rushmore Query Optimization optimizes BLANK FOR if lExpression1 is an optimizable expression. A discussion of Rushmore Query Optimization appears in .
- WHILE lExpression2
Specifies a condition whereby field data in records is cleared as long as the logical expression lExpression2 evaluates to True (.T.).
Prevents Rushmore optimization of BLANK. For more information seeand .
- IN nWorkArea| cTableAlias
Specifies the work area or table alias affected by the BLANK command. Use this clause to specify a work area or a table outside the current work area.
The following example opens the customer table in the testdata database. The contents of the first record are displayed. SCATTER is used to save the contents of the record to an array. The record is cleared with BLANK, and the contents of the record are displayed again. GATHER is used to restore the original record contents, and the restored record contents are displayed again.
CLOSE DATABASES OPEN DATABASE (HOME(2) + 'data\testdata') USE customer && Open customer table CLEAR DISPLAY && Displays the current record SCATTER TO gaCustomer && Create array with record contents BLANK && Clear the record DISPLAY && Displays the blank record GATHER FROM gaCustomer && Restore original record contents DISPLAY && Display the restored record