ストリーム指向データ伝送を使用して連続データ・セットを作成する方法が、図 8 に示されています。最初に、数人の名前と誕生日のリストを含むデータ・セット BDAY.INP からデータが読み取られます。次に、誕生日が 10 月である人の名前と誕生日を含む連続データ・セット BDAY.OCT が書き込まれます。
ディスク・ファイル BDAY.INP を入力データ・セットと関連付けるには、コマンド SET DD:SYSIN=BDAY.INP を使用してください。PL/I プログラムによってこのファイルが作成されなかった場合、RECSIZE オプションも指定する必要があります。
連続出力ファイル WORK をディスク・データ・セット BDAY.OCT と関連付けるには、コマンド SET DD:WORK=BDAY.OCT を使用してください。
/********************************************************************/
/* */
/* DESCRIPTION */
/* Create a CONSECUTIVE data set with 30-byte records containing */
/* names and birthdays of people whose birthdays are in October. */
/* */
/* USAGE */
/* The following commands are required to establish */
/* the environment variables to run this program: */
/* */
/* SET DD:WORK=BDAY.OCT */
/* SET DD:SYSIN=BDAY.INP,RECSIZE(80) */
/********************************************************************/
BDAY: proc options(main);
dcl Work file stream output,
1 Rec,
3 Name char(19),
3 BMonth char(3),
3 Pad1 char(1),
3 BDate char(2),
3 Pad2 char(1),
3 BYear char(4);
dcl Eof bit(1) init('0'b);
dcl In char(30) def Rec;
on endfile(sysin) Eof='1'b;
open file(Work) linesize(400);
get file(sysin) edit(In)(a(30));
do while (¬Eof);
if BMonth = 'OCT'
then put file(Work) edit(In)(a(30));
else;
get file(sysin) edit(In)(a(30));
end;
close file(Work);
end BDAY;
BDAY.INP contains the input data used at execution time:
LUCY D. MAR 15 1950
REGINA W. OCT 09 1971
GARY M. DEC 01 1964
PETER T. MAY 03 1948
JANE K. OCT 24 1939