EDIT$TO$CREDIT:
DO;
/******************************************************************************
*   THIS PROGRAM READS IN A FILE, THEN MASKS OUT BIT 7, AND WRITES IT BACK    *
*   TO THE DISK FROM WHICH IT WAS WRITTEN, BUT WITH THE EXTENSION .TMP        *
******************************************************************************/

   OPEN: PROCEDURE (AFTN$PTR,FILE,ACCESS,MODE,STATUS) EXTERNAL;
      DECLARE (AFTN$PTR,FILE,ACCESS,MODE,STATUS) ADDRESS;
   END OPEN;

   ERROR: PROCEDURE (ERRNUM) EXTERNAL;
      DECLARE (ERRNUM) ADDRESS;
   END ERROR;

   SEEK: PROCEDURE (AFTN,MODE,BLOCKNO,BYTENO,STATUS) EXTERNAL;
      DECLARE (AFTN,MODE,BLOCKNO,BYTENO,STATUS) ADDRESS;
   END SEEK;

   READ: PROCEDURE (AFTN,BUFFER,COUNT,ACTUAL,STATUS) EXTERNAL;
      DECLARE (AFTN,BUFFER,COUNT,ACTUAL,STATUS) ADDRESS;
   END READ;

   WRITE: PROCEDURE (AFTN,BUFFER,COUNT,STATUS) EXTERNAL;
      DECLARE (AFTN,BUFFER,COUNT,STATUS) ADDRESS;
   END WRITE;

   DELETE: PROCEDURE (FILE, STATUS) EXTERNAL;
      DECLARE (FILE, STATUS) ADDRESS;
   END DELETE;

   RENAME: PROCEDURE (OLD$FILE, NEW$FILE, STATUS) EXTERNAL;
      DECLARE (OLD$FILE, NEW$FILE, STATUS) ADDRESS;
   END RENAME;

   CLOSE: PROCEDURE (AFTN,STATUS) EXTERNAL;
      DECLARE (AFTN,STATUS) ADDRESS;
   END CLOSE;

   EXIT: PROCEDURE EXTERNAL;
   END EXIT;

   DECLARE BLOCK$LEN LITERALLY '4096';

   DECLARE DONE                       BYTE;
   DECLARE AFT$IN                     ADDRESS;
   DECLARE AFT$OUT                    ADDRESS;
   DECLARE CRED$FILE(15)              BYTE     DATA (':F1:CRED.SRC   ');
   DECLARE STATUS                     ADDRESS;
   DECLARE COUNT                      ADDRESS;
   DECLARE IN$BUF(BLOCK$LEN)          BYTE;
   DECLARE XFER$CNT                   ADDRESS;
   DECLARE BLOCK$NO                   ADDRESS  DATA(0000H);
   DECLARE BYTE$NO                    ADDRESS  DATA(0000H);
   DECLARE NAME$BUFFER(128)           ADDRESS;
   DECLARE NAME$COUNT                 ADDRESS;

   /* GET FILE NAME                     */
   /* OPEN FILE FOR INPUT               */
   /* CHECK FOR ERROR                   */
   /* OPEN TEMP FILE FOR OUTPUT         */
   /* CHECK FOR ERROR                   */
   /* SET DONE=0                        */
   /* MOVE MARKER TO BEGINNING OF FILE  */
   /* CHECK FOR ERROR                   */
   /* READ IN DATA --MORE ON THIS LATER */
   /* AND DATA WITH 7FH                 */
   /* WRITE DATA TO OUTPUT FILE         */
   /* SEE IF EOF--IF NOT, GO BACK 3     */
   /* CLOSE FILE USED FOR INPUT         */
   /* CHECK FOR ERROR                   */
   /* CLOSE FILE USED FOR OUTPUT        */
   /* CHECK FOR ERROR                   */
   /* DELETE EDIT FILE                  */
   /* RENAME CREDIT FILE TO EDIT FILE   */
   /* EXIT TO ISIS                      */

   CALL READ(1,.NAME$BUFFER,128,.NAME$COUNT,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL OPEN(.AFT$IN,.NAME$BUFFER,1,0,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL OPEN(.AFT$OUT,.CRED$FILE,2,0,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   DONE=0;

   CALL SEEK(AFT$IN,2,.BLOCK$NO,.BYTE$NO,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   DO WHILE NOT DONE;

      CALL READ(AFT$IN,.IN$BUF,BLOCK$LEN,.XFER$CNT,.STATUS);
      IF STATUS <> 0 THEN CALL ERROR(STATUS);

      DO COUNT=0 TO BLOCK$LEN-1;
         INBUF(COUNT)=INBUF(COUNT) AND 7FH;
      END;

      CALL WRITE(AFT$OUT,.INBUF,XFER$CNT,.STATUS);
      IF STATUS <> 0 THEN CALL ERROR(STATUS);

      IF XFER$CNT <> BLOCK$LEN THEN DONE=1;

   END;

   CALL CLOSE(AFT$IN,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL CLOSE(AFT$OUT,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL DELETE(.NAME$BUFFER,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL RENAME(.CRED$FILE,.NAME$BUFFER,.STATUS);
   IF STATUS <> 0 THEN CALL ERROR(STATUS);

   CALL EXIT;

END EDIT$TO$CREDIT;
