PROGRAM GNBCHK;
TYPE
  BUFFER= ARRAY[0..1023] OF BYTE;
VAR
  FIN : FILE OF BUFFER;
  FOUT : TEXT;
  CH : CHAR;
  I,J,N,SKIP,NREC:INTEGER;
  STR:STRING;
  HFLNEXT: INTEGER;

BEGIN
  WRITELN('ENTER FILENAME TO READ');
  READLN(STR);
  WRITELN('ENTER NUMBER OF SECTORS TO SKIP');
  READLN(SKIP);
  WRITELN('ENTER NUMBER OF SECTORS TO READ');
  READLN(NREC);
  ASSIGN(FOUT,'LST:');
  REWRITE(FOUT);
  ASSIGN(FIN,STR);
  RESET(FIN);
  
  HFLNEXT:=IORESULT;
  WRITELN(FOUT,'IORESULT FOR INPUT FILE= ',HFLNEXT);
  HFLNEXT:=0;
  J:=0;
  N:=1;
  WHILE (N<=NREC) DO
    BEGIN
      IF N>SKIP THEN WRITELN(FOUT,'SECTOR=',N);
      FOR I:=1 TO 128 DO
        BEGIN
          CH:=GNB(FIN);
          IF N>SKIP THEN WRITEHEX(FOUT,CH,1);
          IF (I MOD 40=0 ) AND (N>SKIP) THEN WRITELN(FOUT);
          IF ORD(CH)=10 THEN
            BEGIN
              J:=J+1;
              IF N>SKIP THEN
                BEGIN
                  WRITELN(FOUT,'  NREC=',J);
                  WRITELN(FOUT,'EOF= ',EOF(FIN),' IORESULT= ',
                   IORESULT,'  HFLNEXT= ',HFLNEXT)
               END;
            END;
        END;
      N:=N+1;
    END;

        WRITELN(FOUT,'EOF= ',EOF(FIN),' IORESULT= ',
                   IORESULT,'  HFLNEXT= ',HFLNEXT);
  WRITELN(FOUT,'NORMAL END');
  CLOSE(FOUT,I)

END.
      

