17. Forms Statements : clear Statement--Clears the Screen or Fields
 
Share this page                  
clear Statement--Clears the Screen or Fields
This statement clears the screen, individual fields on the form, or all fields on the form.
Syntax
clear screen
clear field
fieldname {, fieldname}|all
Description
The clear statement clears the screen or the fields on a form. You can issue a clear screen statement anywhere in a forms-based program. (To clear a single row, use the clearrow statement.)
You can specify fieldname using a quoted or unquoted character string or host string variable. Fieldname can specify a simple field or a table field; if you specify a table field, clear field clears the contents of the associated data set as well as the display. The fieldname cannot specify a derived field; clear field cannot clear derived fields.
To clear the screen, use the clear screen option. Clear screen does not remove any data from the form's fields; if you redisplay the form, the fields displays the same data they held when the screen was cleared.
The clear field option clears data from the specified fieldnames and sets each cleared field's change variable to 0. Clear field all clears all field change variables, but does not clear the form's change variable. Derived fields that depend on a field that has been cleared are also cleared. Unlike the clear screen option, data in the cleared fields is not recoverable.
By default, when you clear a nullable field, blanks are placed in the field's display. You can override this default by defining the logical environment variable, II_NULL_STRING. When you do so, the value contained in II_NULL_STRING is placed in the field instead of blanks.
You must issue the clear field statement within the execution scope of a form's display loop. However it is not required to be syntactically within the display block: the clear field statement can be executed in a routine or procedure that is called from within the display loop.
Examples--clear statement:
Example 1:
Present the user with a blank screen, followed by a message.
exec frs clear screen;
exec frs message 'Initializing ...';
Example 2:
Clear the data in the salary and dept fields.
exec frs clear field salary, dept;
Example 3:
Clear the data in the field specified by the program variable fieldvar.
exec frs clear field :fieldvar;
Example 4:
Clear the data set of the employee table field.
exec frs clear field employee;