How to: |
The FIND function determines if a data value is in a data source field being searched. The function sets a temporary field to 1 (a non-zero value for MODIFY) if the data value is found in the data source field, and to 0 if it is not. FIND does not change the searched file's current database position. A value greater than zero confirms the presence of the data value, not the number of instances in the data source field.
Note: For MODIFY only, the FIND function verifies the existence of a incoming data value in an indexed FOCUS data source field.
You can also use FIND in a VALIDATE command to determine if a transaction field value exists in another FOCUS data source. If the field value is not in that data source, the function returns a value of 0, causing the validation test to fail and the request to reject the transaction.
You can use any number of FINDs in a COMPUTE or VALIDATE command. However, more FINDs increase processing time and require more buffer space in memory.
Limit: FIND does not work on files with different DBA passwords.
The opposite of FIND is NOT FIND. The NOT FIND function sets a temporary field to 1 if the incoming value is not in the data source and to 0 if the incoming value is in the data source.
FIND(fieldname [AS dbfield] IN file);
where:
Is the name of the field that contains the incoming data value.
Is the name of the data source field whose values are compared to the incoming field values.
For MODIFY - the AS field must be indexed. If the incoming field and the data source field have the same name, omit this phrase.
Is the name of the FOCUS data source.
For MODIFY - the IN field must be indexed.
FIND determines if a supplied value in the EMP_ID field is in the EDUCFILE data source. The procedure then displays a message indicating the result of the search.
MODIFY FILE EMPLOYEE PROMPT EMP_ID COMPUTE EDTEST = FIND(EMP_ID IN EDUCFILE); MSG/A40 = IF EDTEST NE 0 THEN 'STUDENT LISTED IN EDUCATION FILE' ELSE 'STUDENT NOT LISTED IN EDUCATION FILE'; MATCH EMP_ID ON NOMATCH TYPE "<MSG" ON MATCH TYPE "<MSG" DATA
A sample execution is:
> EMPLOYEE ON 12/04/2001 AT 12.09.03 DATA FOR TRANSACTION 1 EMP_ID = 112847612 STUDENT LISTED IN EDUCATION FILE DATA FOR TRANSACTION 2 EMP_ID = 219984371 STUDENT NOT LISTED IN EDUCATION FILE DATA FOR TRANSACTION 3
The procedure processes as follows:
The following updates the number of hours an employee spent in class. The VALIDATE command rejects a transaction for an employee whose ID is not found in the EDUCFILE data source, which records class attendance.
MODIFY FILE EMPLOYEE PROMPT EMP_ID ED_HRS VALIDATE EDTEST = FIND(EMP_ID IN EDUCFILE); MATCH EMP_ID ON NOMATCH REJECT ON MATCH UPDATE ED_HRS DATA
A sample execution is:
> EMPLOYEE ON 12/04/2001 AT 12/26/08 DATA FOR TRANSACTION 1 EMP_ID = 112847612 ED_HRS = 7 DATA FOR TRANSACTION 2 EMP_ID = 219984371 ED_HRS = 0 (FOC421) TRANS 2 REJECTED INVALID EDTEST 219984371, 0, $ DATA FOR TRANSACTION 3
The procedure processes as follows:
EMP_ID: 112847612 ED_HRS: 7
EMP_ID: 219984371 ED_HRS: 0