%FOUND (検出条件の戻し)

%FOUND{(file_name)}

%FOUND は、最後に実行された関係のあるファイル命令がレコードを見付けたり、 ストリング命令が等しい項目を見付けたり、検索命令が要素を見付けたりした 場合、'1' を戻します。他の場合、この関数は '0' を戻します。

%FOUND を設定する命令を以下に示します。

任意指定のファイル名パラメーターを指定しないで %FOUND を使用した場合、この 関数は、最後に実行された関係のある命令について設定された値を戻します。 ファイル名を指定すると、この関数は、そのファイルで最後に実行された関係のある命令に適用されます。

ファイル命令の場合、%FOUND の機能 は "レコードが見付からない NR" 標識の逆です。

ストリング命令の場合、%FOUND の機能は "検出 FD" 標識と 同じです。

LOOKUP 命令の場合、%FOUND は、検索条件を満たす要素を命令が見付けると、'1' を 戻します。 LOOKUP を伴う %FOUND の例については、 図 図 2 を参照してください。

詳細については、ファイル命令結果命令、 または 組み込み関数を参照してください。

図 1. パラメーターを指定しないでファイル命令のテストに使用する %FOUND
 *..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
図 2. パラメーターを指定してファイル命令のテストに使用する %FOUND
 *..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
図 3. ストリング命令をテストするために使用する %FOUND
*...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