Rational Developer for System z
COBOL for Windows バージョン 7.5 プログラミング・ガイド


例: コマンド行引数

この例は、コマンド行引数の読み取り方法を示しています。

 IDENTIFICATION DIVISION.
 PROGRAM-ID. “testarg”.
*
 ENVIRONMENT DIVISION.
 CONFIGURATION SECTION.
*
 DATA DIVISION.
 WORKING-STORAGE SECTION.
*
 linkage section.
 01  os-parm.
     05 parm-len         pic s999 comp.
     05 parm-string.
         10 parm-char    pic x occurs 0 to 100 times
                         depending on parm-len.
*
 PROCEDURE DIVISION using os-parm.
     display “parm-len=” parm-len
     display “parm-string='” parm-string “'”
     evaluate parm-string
       when “01”  display “case one”
       when “02”  display “case two”
       when “95”  display “case ninety-five”
       when other display “case unknown”
     end-evaluate
     GOBACK.

以下のように、このプログラムをコンパイルして実行するとします。

cob2 testarg.cbl

testarg 95

結果の出力は、次のとおりです。

parm-len=002
parm-string='95'
case ninety-five

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

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