Rational Developer for System z
PL/I for Windows, Version 8.0, プログラミング・ガイド

対話式プログラムの例

図 13 のプログラム例では、ユーザーとのダイアログを使用して連続データ・セット PHONES を作成します。デフォルトでは、SYSIN が CON 装置に関連付けられています。SYSIN ファイル用の環境変数を設定するか、または OPEN ステートメントの TITLE オプションを使用することによって、この関連付けを指定変更することができます。出力データ・セットは、ディスク・ファイル INT1.DAT に関連付けられ、ユーザーがキーボードから入力した名前と電話番号を格納します。

図 13. 対話式プログラムのサンプル
 /********************************************************************/
 /*                                                                  */
 /*  DESCRIPTION                                                     */
 /*    Create a SEQUENTIAL data set using a console dialog.          */
 /*                                                                  */
 /*  USAGE                                                           */
 /*    The following command is required to establish                */
 /*    the environment variable to run this program:                 */
 /*                                                                  */
 /*      SET DD:PHONES=INT1.DAT,APPEND(Y)                            */
 /*                                                                  */
 /********************************************************************/

 INT1: proc options(main);

   dcl Phones stream env(recsize(40));

   dcl Eof bit(1) init('0'b);

   dcl 1 PhoneBookEntry,
        3 NameField char(19),
        3 PhoneNumber char(21);
   dcl InArea char(40);

   open file (Phones) output;

   on endfile(sysin) Eof='1'b;

   /* start creating phone book */
   put list('Please enter name:');
   get edit(NameField)(a(19));
   if ¬Eof then
    do;
      put list('Please enter number:');
      get edit(PhoneNumber)(a(21));
    end;
   do while (¬Eof);
      put file(Phones) edit(PhoneBookEntry)(a(40));
      put list('Please enter name:');
      get edit(NameField)(a(19));
      if ¬Eof then
       do;
         put list('Please enter number:');
         get edit(PhoneNumber)(a(21));
       end;
   end;

   close file(Phones);

 end INT1;

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)