変数は反復子の使用地点で宣言でき、その範囲は perform ブロックの最後までになります。
*> この場合、i の範囲は perform ブロックの最後までになる perform varying i as binary-long from 1 by 1 until i > 10 display i end-perform *> そのため、次の perform ブロック内の i は i の新しいインスタンスになる *> 先行する perform ブロック内の i とは関係ない 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
ローカル変数のサンプルも参照してください。このサンプルは、[スタート > すべてのプログラム > Micro Focus Visual COBOL > Samples] の COBOL for JVM の下にあります。