REM RANDOM read mailbox file REM buffering sectors with random access REM and replacing eof and lf characters TYPE SECTOR BYTES AS STRING * 512 END TYPE DIM RECORD AS SECTOR REM initialize RECORD.BYTES = STRING$(512," ") REM open files INPUT "input filename: ";F$ INPUT "output filename: ";O$ OPEN F$ FOR RANDOM AS #1 LEN = LEN(RECORD) OPEN O$ FOR RANDOM AS #2 LEN = LEN(RECORD) INPUT "want a log file (Y/N)";A$ L = 0 IF A$ = "Y" THEN L = 1 OPEN "log." FOR OUTPUT AS #3 ELSEIF A$ = "y" THEN L = 1 OPEN "log." FOR OUTPUT AS #3 END IF OPEN "echo." FOR OUTPUT AS #4 REM initialize sector counter: I = 0 DO WHILE NOT EOF(1) REM increment sector counter I = I + 1 REM save sector's last byte Z$ = MID$(RECORD.BYTES,512,1) REM read next sector GET #1, I, RECORD REM look thru bytes FOR J = 1 TO 512 REM pull byte "J": C$ = MID$(RECORD.BYTES,J,1) REM convert to numeric equivalent K = ASC(C$) REM log this result IF L = 1 THEN PRINT #3, "byte ";C$;" is ";K END IF REM check for new paragraph (12) or eof (26) IF K = 12 OR K = 26 THEN REM change to cr (13) C$ = CHR$(13) MID$(RECORD.BYTES,J,1) = C$ REM log this result: IF L = 1 THEN PRINT #3, "byte (";K;") changed to ( 13 ) in sector";I PRINT #4, "byte (";K;") changed to ( 13 ) in sector";I END IF END IF REM check for line feed (10) IF K = 10 THEN REM check for cr/lf sequence: IF J = 1 THEN REM check previous sector N = ASC(Z$) IF N <> 13 THEN REM change to cr (13) C$ = CHR$(013) MID$(RECORD.BYTES,1,1) = C$ REM log this result: IF L = 1 THEN PRINT #3, "byte ( 10 ) changed to ( 13 )" PRINT #4, "byte ( 10 ) changed to ( 13 )" END IF END IF ELSE M = J - 1 B$ = MID$(RECORD.BYTES,M,1) N = ASC(B$) REM check for cr/lf: IF N <> 13 THEN REM change to carriage return ("cr") C$ = CHR$(013) MID$(RECORD.BYTES,J,1) = C$ REM log this result: IF L = 1 THEN PRINT #3, "byte (10) changed to (13)" PRINT #4, "byte (10) changed to (13)" END IF END IF END IF END IF NEXT J REM write this record: PUT #2, I, RECORD PRINT "wrote sector ";I PRINT #4, "wrote sector ";I REM get next record: LOOP CLOSE PRINT "number of sectors written: ";I PRINT "all done!" STOP END