Epi Info™ User Guide
Check Commands: CLEAR
CLEAR sets the field or fields that follow the command to the missing value as if they had been left blank. The command is used to clear a previous entry when an error has been detected or a change occurs.
Note: One or more fields can be used with the CLEAR command in a single statement. Specify a group field in a CLEAR command to clear all fields contained within the group.
CLEAR <field1> <field2> <field3> <fieldN>
- The <field> represents the name of a field on the form. If more than one field is specified, separate each field with a single blank space.
CLEAR will delete the value only for the current record. CLEAR cannot be used in grid tables.
To try the code examples below, copy and paste the code example into the Form Designer Check Code Editor, then run the form in Enter. The code example may require specific fields to be on the form.
Example 1: The code below prevents invalid data from being saved to the current record by erasing it as soon as it is detected. The example assumes a form exists with the following field: Age (Numeric). The code below would appear in the AFTER section of the Age field.
Field Age After IF Age >= 18 THEN BEEP DIALOG "Do not include records for adults." CLEAR Age END-IF End-After End-Field
Example 2: The code below prevents an invalid date from being saved to the current record by erasing it as soon as it is detected. The example assumes a form exists with the following fields: DOB (Date) and SurveyDate (Date). The code below would appear in the AFTER section of the SurveyDate field.
Field SurveyDate After IF (DOB > SurveyDate) OR (SurveyDate > SYSTEMDATE) THEN CLEAR DOB SurveyDate DIALOG "Invalid date detected. Please try again." TITLETEXT="Error" END-IF End-After End-Field
Example 3: The code below enables or disables a field representing the patient’s pregnancy status based on the value selected for the patient’s sex. If value of PatientSex is “Male”, the CLEAR command is used to erase any value that might have been accidentally entered for the PregnancyStatus field. This example assumes a form exists with the following fields: PatientSex (Legal Value) and PregnancyStatus (Yes-No). The code below would appear in the AFTER section of the PatientSex field.
Field PatientSex After IF PatientSex = "Male" THEN CLEAR PregnancyStatus DISABLE PregnancyStatus ELSE ENABLE PregnancyStatus END-IF End-After End-Field