ローカル・データ項目の宣言

ローカル・データ項目は、手続き部本文で宣言されるデータ項目 (変数とも呼ばれる) です。

local-declaration

type-specifier

       declare i1 as binary-long
       display i1 
         
       *>   オプションで、変数をインラインで初期化可能 
        declare c2 as condition-value = true
        display c2

        declare string-list2 as string occurs 3 = table of string("Bill", "Ben", "LittleWeed")   

      **************************************************************************
      * オプションで、変数をインラインで初期化可能 
      **************************************************************************

      *>   変数は反復子の使用時に宣言可能 
      *>   この場合、i の範囲は end-perform までになる 
           perform varying i as binary-long from 1 by 1 until i > 10
               display i
           end-perform

      **************************************************************************
      * Exception Variables
      **************************************************************************
       
      *>   次の例は、使用時に e を宣言できることを示す
      *>   範囲は end-try まで
           try
               display "exception test"
           catch e as type Exception
               display e::Message
           end-try

ローカル変数のサンプルも参照してください。このサンプルは、[スタート > すべてのプログラム > Micro Focus Enterprise Developer > Samples] の COBOL for JVM の下にあります。

その他の情報

インライン・ローカル変数の範囲は、宣言のポイントから最奥の包含ブロックの最後までです。段落、セクション、メソッド全体は、ブロックと見なされます。