%FOUND{(file_name)}
%FOUND returns '1' if the most recent relevant file operation found a record, a string operation found a match, or a search operation found an element. Otherwise, this function returns '0'.
The operations that set %FOUND are:
If %FOUND is used without the optional file_name parameter, then it returns the value set for the most recent relevant operation. When a file_name is specified, then it applies to the most recent relevant operation on that file.
For file operations, %FOUND is opposite in function to the "no record found NR" indicator.
For string operations, %FOUND is the same in function as the "found FD" indicator.
For the LOOKUP operation, %FOUND returns '1' if the operation found an element satisfying the search conditions. For an example of %FOUND with LOOKUP, see Figure Figure 217.
For more information, see File Operations, Result Operations, or Built-in Functions.
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
F*Filename+IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++
* File CUSTS has record format CUSTREC
FCUSTS IF E K DISK
/FREE
// Check if the customer is in the file
chain Cust CustRec;
if %found;
exsr HandleCustomer;
endif;
/END-FREE
*..1....+....2....+....3....+....4....+....5....+....6....+....7...+....
F*Filename+IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++
* File MASTER has all the customers
* File GOLD has only the "privileged" customers
FMASTER IF E K DISK
FGOLD IF E K DISK
/FREE
// Check if the customer exists, but is not a privileged customer
chain Cust MastRec;
chain Cust GoldRec;
// Note that the file name is used for %FOUND, not the record name
if %found (Master) and not %found (Gold);
//
endif;
/END-FREE
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++
D Numbers C '0123456789'
D Position S 5I 0
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
* If the actual position of the name is not required, just use
* %FOUND to test the results of the SCAN operation.
* If Name has the value 'Barbara' and Line has the value
* 'in the city of Toronto. ', then %FOUND will return '0'.
* If Line has the value 'the city of Toronto where Barbara lives, '
* then %FOUND will return '1'.
C Name SCAN Line
C IF %FOUND
C EXSR PutLine
C ENDIF
* If Value contains the value '12345.67', Position would be set
* to 6 and %FOUND would return the value '1'.
* If Value contains the value '10203040', Position would be set
* to 0 and %FOUND would return the value '0'.
C Numbers CHECK Value Position
C IF %FOUND
C EXSR HandleNonNum
C ENDIF