I excluded the part which does the " 5 record database
simulation". This stuff is old hat.
/* 3. CANT provide varying record database support */
dcl testf file record; DCL eof bit(1) init('0'B);
DCL datarec char(104); dcl 1 typ1 based(addr(datarec)), 2
nf fixed bin(31), 2 date(3) fixed bin(31);
dcl 1 typ2 based(addr(datarec)),
2 nf fixed bin(31),
2 n fixed bin(31),
2 winners char(100);
dcl 1 typ3 based(addr(datarec)), 2 nf fixed bin(31), 2
commt char(100);
on endfile (testf) eof = '1'B; eof = '0'B;
open file(testf) input; datarec = ''; read file(testf)
into (datarec);
do while(^eof); select(typ1.nf); when(1) put
edit(typ1.date)(R(t1)); when(2) put edit('lotto winners:
',typ2.winners)(R(t2)); other put edit('unrecog. record
format = ',typ1.nf)(R(tx)); end; datarec = ''; read
file(testf) into (datarec); /* get next record */ end;
close file(testf);
t1: format (skip, p'99B', p'99B', p'99'😉;
t2: format (skip, a(15), a(length(trim(typ2.winners))));
tx: format (skip, a, a);
/*Outputs: 07 20 03 07 21 03 lotto winners: john doe,
anthony soprano 07 22 03 unrecog. record format = 100 */
--
Tim C.