![]() |
declare i1 as binary-long
display i1
*> Optionally, the variables can be initialised inline
declare c2 as condition-value = true
display c2
declare string-list2 as string occurs 3 = table of string("Bill", "Ben", "LittleWeed")
**************************************************************************
* Iteration Variables
**************************************************************************
*> A variable can be declared at the point of use in an iterator.
*> In this case the scope of i will be until the end-perform.
perform varying i as binary-long from 1 by 1 until i > 10
display i
end-perform
**************************************************************************
* Exception Variables
**************************************************************************
*> The example below shows that you can declare e at the point of use.
*> It is in scope until the end-try.
try
display "exception test"
catch e as type Exception
display e::Message
end-try
ローカル変数のサンプルも参照してください。このサンプルは、[スタート > すべてのプログラム > Micro Focus Enterprise Developer > Samples > Visual COBOL Samples]、 の場合JVM COBOL 言語リファレンスの場合。 に用意されています。
インライン ローカル変数の範囲は、宣言のポイントから最奥の包含ブロックの最後までです。段落、節、メソッド全体は、ブロックと見なされます。
ローカル項目の宣言で複数の型に解決できる型の名前が参照されている場合、それらの型の一方が現在のコンパイル単位内で宣言されていて、もう一方が外部で定義されていれば、内部の型を参照しているものと見なされます。両方の型が現在のコンパイル単位内で宣言されている場合、または両方とも外部で定義されている場合は、エラーが生成されます。