PERFORM 文

PERFORM 文の範囲で文ブロックの実行を制御する。この文は、配列または集合の各要素も処理できる。

Context:

    手続き部
        

perform-statement

注: Other formats of this statement are available. See in the COBOL 言語リファレンス.

その他の情報

JVM COBOL の場合、USING 指定は JVM バージョン 1.7 以降にのみ適用されます。

PERFORM..USING 指定の type-specifier セクションでは、java.lang.AutoCloseable インタフェースを実装する型を指定する必要があり、= expression 構文を使用して初期値を指定する必要があります。

反復子内のローカル宣言の例

変数は反復子の使用地点で宣言でき、その範囲は perform ブロックの最後までになります。

      *>   In this case, the scope of i is until the end of the perform block. 
           perform varying i as binary-long from 1 by 1 until i > 10
               display i
           end-perform

      *>   So the i in the following perform block is a new instance of i,
      *>   independent of the i in the preceding perform block.
           perform varying i as binary-short from 0 by 1 until i > 10
               display i
           end-perform

ここで、k がインラインで宣言され、辞書を反復します。繰り返しになりますが、範囲は、対応する end-perform までになります。

    01 dict1 dictionary[string string].
           create dict1
           write dict1 from "Anthony" key "A"
           write dict1 from "Brian" key "B"
           write dict1 from "Charles" key "C"
           perform varying key k as string value val as string through dict1
               display k ":" val
           end-perform
           perform varying value val as string through dict1
               display val
           end-perform
           perform varying key k as string through dict1
               display k
           end-perform

ローカル変数サンプルも参照してください。このサンプルは、サンプル ブラウザーに用意されています。手順については、「サンプル ブラウザーを起動するには」を参照してください。