Rational Developer for System z
Enterprise COBOL for z/OS バージョン 4.1 プログラミング・ガイド


例: メインプログラム・パラメーターへのアクセス

次の例は、参照によって渡される 3 つのパラメーターを示しています。

 Identification division.
 Program-id. "EXECED".
****************************************************************
* This sample program displays arguments received via exec()   *
* function of z/OS UNIX                                        *
****************************************************************
 Data division.
 Working-storage section.
 01 curr-arg-count pic 9(9) binary value zero.
 Linkage section.
 01 arg-count pic 9(9) binary.                     (1)
 01 arg-length-list.                               (2)
     05 arg-length-addr pointer occurs 1 to 99999
           depending on curr-arg-count.
 01 arg-list.                                      (3)
     05 arg-addr pointer occurs 1 to 99999
           depending on curr-arg-count.
 01 arg-length pic 9(9) binary.
 01 arg pic X(65536).
 Procedure division using arg-count arg-length-list arg-list.
*****************************************************************
* Display number of arguments received                          *
*****************************************************************
     Display "Number of arguments received: " arg-count
*****************************************************************
* Display each argument passed to this program                  *
*****************************************************************
     Perform arg-count times
       Add 1 to curr-arg-count
* *******************************************************
* * Set address of arg-length to address of current     *
* * argument length and display                         *
* *******************************************************
       Set Address of arg-length
         to arg-length-addr(curr-arg-count)
       Display
         "Length of Arg " curr-arg-count " = " arg-length
* *******************************************************
* * Set address of arg to address of current argument   *
* * and display                                         *
* *******************************************************
       Set Address of arg to arg-addr(curr-arg-count)
       Display "Arg " curr-arg-count " = " arg (1:arg-length)
     End-Perform
     Display "Display of arguments complete."
     Goback.
(1)
このカウントには、2 番目および 3 番目のパラメーターで渡される配列のエレメントの数が含まれています。
(2)
この配列には、引数リスト内の n 番目の記入項目の長さへのポインターが含まれています。
(3)
この配列には、spawn() 関数、exec() 関数、またはコマンド呼び出しで引数として渡される n 番目の文字ストリングへのポインターが含まれています。

ご利用条件 | フィードバック

このインフォメーション・センターでは Eclipse テクノロジーが採用されています。(http://www.eclipse.org)