Program TstQIOIBM;

{ Version
  File:[22,311]TSTQIOIBM.PAS
  Author: Peter Stadick 
  History: Derived from TSTQIOWRP from Philip Hannay  1-Aug-85


Testing P3UTIL module(s): QIOIBM

}

{$nolist}
{[a+,b+,l-,k+,r+] Pasmat }
%INCLUDE 'EX:[22,320]GENERAL3.TYP';
%INCLUDE '[22,320]QIOIBM.EXT';

{$list}

Var
  ids, i, j, lunnum, outsiz, insiz, timeout: integer;
  iefn, efnnumr, efnnumw: Event_flag;
  iostat: IO_status_block;
  outbuf,inbuf: ch60;
  outadr,inadr, ttableadr: address;
  done: boolean;
  ttable : ARRAY [1..16] OF word;

BEGIN
done:= false;
writeln('QIOIBM (series one commumications) test');
for i := 1 to 16 do
  ttable[i] := 0;
{ 32 is a CTRL E}
ttable[1] := 2; 
ttableadr := LOOPHOLE(address,REF(ttable));
repeat
writeln;
write('Enter LUN number> ');
if not(eoln) 
  then  begin
    readln(lunnum);
    write('Enter event read flag number> ');
    readln(i);
    efnnumr:= f0;
    for iefn:= f0 to f96 do if ord(iefn)=i then efnnumr:= iefn;
    write('Enter event write flag number> ');
    readln(i);
    efnnumw:= f0;
    for iefn:= f0 to f96 do if ord(iefn)=i then efnnumw := iefn;
    writeln('Enter output prompt (up to 60 chars): ');
    writeln('0        1         2         3         4         5         6');
    writeln('123456789012345678901234567890123456789012345678901234567890');
    readln(outbuf);
    outadr:= LOOPHOLE(Address,Ref(outbuf));
    write('Enter output prompt size> ');
    readln(outsiz);
    write('Enter timeout value (negative = no timeout)> ');
    readln(timeout);
    inadr:= LOOPHOLE(Address,Ref(inbuf));
    for i:=1 to 60 do inbuf[i]:=' ';
    repeat
      write('Enter input buffer size (up to 60)> ');
      readln(insiz);
    until (insiz >= 0) and (insiz <= 60);
    {done with parameter entry, lets call procedure}
    writeln;
    writeln('Calling QIOWRP procedure....');
    QIOIBM(lunnum,efnnumr,efnnumw,inadr,insiz,timeout,outadr,outsiz,ttableadr,
           iostat);
    ids:= $DSW;
    writeln;
    writeln('Returned from QIOWRP procedure');
    writeln;
    writeln('ids=',ids:1);
    writeln('Input chars="',inbuf,'"');
    i:=iostat[1] div 256; {high byte}
    j:=iostat[1] mod 256; {low byte}
    writeln('iostat[1]=',iostat[1]:1,'  low byte=',j:1,' high byte=',i:1);
    writeln('iostat[2]=',iostat[2]:1);
    end
  else begin
    done:= true
    end;
until done;
writeln;
writeln('end of test.');
writeln;
end.

