      LOGICAL*1 FUNCTION NXTCHR (IDUMMY)                                  00001 
C        THIS FUNCTION REPLACES THE EQUIVALENT CDC NXTCHR FUNCTION        00002 
C     IN THE PDP ENVIRONMENT.                                             00003 
C        RETURNS NEXT BYTE FROM IBLK                                      00004 
C        IDUMMY IS A DUMMY ARGUMENT (NOT USED)                            00005 
C        THE FOLLOWING COMMONS ARE USED:                                  00006 
C                                                                         00007 
      INCLUDE 'SY:BCOM.FTN'                                               00008 
      INCLUDE 'SY:MTCOMM.FTN'                                             00009 
      INCLUDE 'SY:CVCOM.FTN'                                              00010 
      INCLUDE 'SY:FLGCM.FTN'                                              00011 
      INCLUDE 'SY:LDCOM.FTN'                                              00012 
      INCLUDE 'SY:MTFCB.FTN'                                              00013 
C                                                                         00014 
C        LOCAL VARIABLES ARE-                                             00015 
C                                                                         00016 
C                                                                         00017 
C                                                                         00018 
C                                                                         00019 
C                                                                         00020 
C     CLEAR FLAGS (IS THIS EVENTUALLY NECESSARY? ***)                     00021 
      FTERM=.FALSE.                                                       00022 
      RTERM=.FALSE.                                                       00023 
      USEP= .FALSE.                                                       00024 
      FSEP =.FALSE.                                                       00025 
C                                                                         00026 
C     CHECK IF A NEW BLOCK IS NEEDED                                      00027 
C                                                                         00028 
      IF (IBCH .LT. IBCT) GOTO 140                                        00029 
C                                                                         00030 
C        READ THE NEXT BLOCK FROM TAPE                                    00031 
C                                                                         00032 
      ASSIGN 32757 TO I32758                                              00033 
      GO TO 32758                                                         00033 
32757 IF (MAGEND)  GOTO 300                                               00034 
      IF (MAGERR)  GOTO 700                                               00035 
C        INCREASE THE BLOCKS READ COUNTER                                 00036 
      KTBLK=KTBLK+1                                                       00037 
C                                                                         00038 
C        GET SIZE OF RECORD READ IN BYTES                                 00039 
      IBCT=NBUFER                                                         00040 
C                                                                         00041 
      TYPE 20,KTBLK,NBUFER                                                00042 
20    FORMAT(' NXTCHR READ BLOCK ',I4,' SIZE=',I5)                        00043 
C                                                                         00044 
C        GET SPANNING CHARACTER FROM BLOCK                                00045 
C                                                                         00046 
      SPAN=IBLK(1)-48                                                     00047 
C                                                                         00048 
C        GET RECORD SIZE FROM BLOCK                                       00049 
      DECODE(4,70,IBLK(2)) IRCT                                           00050 
70    FORMAT(I4)                                                          00051 
C                                                                         00052 
C        SET RECORD SIZE EXTRACTED FROM BLOCK INDICATOR                   00053 
      NBLK=1                                                              00054 
      ISCT=5                                                              00055 
      IBCH=5                                                              00056 
C                                                                         00057 
C        GET NEXT CHARACTER FROM THE BLOCK                                00058 
 140  IBCH=IBCH+1                                                         00059 
      ITMP=IBLK(IBCH)                                                     00060 
      ISCT=ISCT+1                                                         00061 
C                                                                         00062 
C        CHECK FOR TERMINATOR CHARACTERS                                  00063 
      INDX=ITMP                                                           00064 
      IF (INDX .EQ. 30) FTERM=.TRUE.                                      00065 
      IF (INDX .EQ. 29) RTERM=.TRUE.                                      00066 
      IF (INDX .EQ. 31) USEP =.TRUE.                                      00067 
      IF (RTERM) NBLK=0                                                   00068 
      IF (INDX .NE. 28) GOTO 210                                          00069 
      FSEP=.TRUE.                                                         00070 
      RTERM=.TRUE.                                                        00071 
      NBLK=0                                                              00072 
        IEOF=.TRUE.                                                       00073 
        IBCH=IBCT                                                         00074 
C                                                                         00075 
C        RETURN THE CHARACTER TO THE CALLER                               00076 
 210  NXTCHR=ITMP                                                         00077 
C                                                                         00078 
C     DEBUG MATERIAL ***                                                  00079 
      IF (.NOT. DEBUG) GOTO 220                                           00080 
      IF (FTERM) TYPE 211                                                 00081 
      IF (RTERM) TYPE 212                                                 00082 
      IF (USEP)  TYPE 213                                                 00083 
      IF (FSEP)  TYPE 214                                                 00084 
211   FORMAT(' NXTCHR FIELD TERM')                                        00085 
212   FORMAT(' NXTCHR RECRD TERM')                                        00086 
213   FORMAT(' NXTCHR UNIT  SEP ')                                        00087 
214   FORMAT(' NXTCHR FILE  TERM')                                        00088 
220   CONTINUE                                                            00089 
      IF(ITMP.EQ.94) GO TO 900                                            00090 
      IRCH=IRCH+1                                                         00091 
      GOTO 900                                                            00092 
C                                                                         00093 
C        END OF FILE WAS READ - PROBLEMS                                  00094 
 300  IEOF=.TRUE.                                                         00095 
      TYPE 310,KTBLK,IBCT,IRCT                                            00096 
        IBCH=IBCT+1                                                       00097 
        ISCT=0                                                            00098 
        IRCH=0                                                            00099 
 310  FORMAT(' NXTCHR ***EOF, KTBLK,IBCT,IRCT=',3I5)                      00100 
C                                                                         00101 
C     END OF NXTCHR FUNCTION                                              00102 
900   RETURN                                                              00103 
C                                                                         00104 
C     MAGERR WAS SET TRUE, FOR NOW DUMP MTCOMM AND STOP                   00105 
C                                                                         00106 
700   TYPE 701,MTSUCL,MTPNDL,MTEOFL,MTDSEL,MTIOEL,MTERRL,                 00107 
     1MTWAIT                                                              00108 
701   FORMAT(' MTSUCL=',L1,' MTPNDL=',L1,' MTEOFL=',L1,                   00109 
     1' MTDSEL=',L1,' MTIOEL=',L1,' MTERRL=',L1,' MTWAIT=',L1)            00110 
710   TYPE 711,MTIOS1,MTIOS2                                              00111 
711   FORMAT(' MTIOS1=',O16,' MTIOS2=',O16)                               00112 
      STOP                                                                00113 
C                                                                         00114 
C                                                                         00115 
C     M T R E A D . F L X                                                 00116 
C                                                                         00117 
C                                                                         00118 
C     NOTE ** INCLUDE MTFCB.FTN COMMON DEFINITION                         00119 
C     MAGTAPE PROCEDURES TO READ A TAPE                                   00120 
C                                                                         00121 
C                                                                         00122 
32758 CONTINUE                                                            00123 
      NBUFER=2800                                                         00124 
      MAGERR = .FALSE.                                                    00125 
      CALL MTRLB( MTLUN,LBUFR,NBUFER,ISTAT )                              00126 
      IF(.NOT.( ISTAT.EQ.0 )) GO TO 32756                                 00127 
      MAGEND = .FALSE.                                                    00128 
      NBUFER = MTIOS(2)                                                   00129 
32756 IF(.NOT.( ISTAT.EQ.1 )) GO TO 32755                                 00131 
      ASSIGN 32753 TO I32754                                              00131 
      GO TO 32754                                                         00131 
32753 CONTINUE                                                            00131 
32755 IF(.NOT.( ISTAT.EQ.2 )) GO TO 32752                                 00132 
      IF(.NOT.( MTIOS(1).NE.MTEOFS )) GO TO 32750                         00133 
      ASSIGN 32749 TO I32754                                              00133 
      GO TO 32754                                                         00133 
32749 GO TO 32751                                                         00133 
32750 MAGEND = .TRUE.                                                     00134 
32751 CONTINUE                                                            00135 
32752 GO TO I32758                                                        00136 
C                                                                         00137 
C                                                                         00138 
C*******************                                                      00139 
C                                                                         00140 
C                                                                         00141 
C     ERROR HANDLERS                                                      00142 
C                                                                         00143 
C                                                                         00144 
32754 CONTINUE                                                            00145 
      CALL ERROR( TTLUN,'READ MAGTAPE FAILED',MTDSW,MTIOS )               00146 
      ASSIGN 32747 TO I32748                                              00147 
      GO TO 32748                                                         00147 
32747 GO TO I32754                                                        00148 
32748 CONTINUE                                                            00149 
      MAGERR = .TRUE.                                                     00150 
      GO TO I32748                                                        00151 
      END                                                                 00152 
