BEGIN
INTEGER I,A;
BEGIN
FILE X[40] ; %BLOCKED FILE 40 CHAR'S PER BLOCK%
WRITE("THIS PROGRAM CREATES AND OPENS A CP/M FILE ");
WRITE("WITH A NAME OF BLK.INP.  THIS IS A BLOCKED ");
WRITE("RANDOM ACCESS FILE. IT THEN WRITES THE NUMBERS 1");
WRITE("TO 5 OUT TO THIS FILE, ONE NUMBER PER BLOCK.");
X:="BLK.INP"; %THIS ASSIGNS BLK.INP TO X AND OPENS THE FILE%

A:=0;
WRITE("THE NUMBERS WRITTEN TO THE FILE ARE");
FOR I:=1 STEP 1 UNTIL 5 DO 
  BEGIN
   WRITE X,I((A:=A+1));%X IS THE FILE NAME AND I IS THE RECORD NBR%
   WRITE (A); % THIS WRITES TO THE CONSOLE %
END;
END; % THIS IS THE END OF THE BLOCK IN WHICH  %
     % FILE X IS DECLARED SO AT THIS POINT IT %
     % IS CLOSED %
BEGIN
FILE XI[40]; %THIS IS A NEW BLOCKED FILE %
XI:="BLK.INP"; % FILE XI IS ALSO ASSIGNED TO BLK.INP AND%
               % BLK.INP IS RE-OPENED HERE %
WRITE ("THE NUMBERS IN THE FILE ARE");
FOR I:=1 STEP 1 UNTIL 5 DO
  BEGIN
     READ XI,I(A); % THIS READS FROM FILE XI RECORD I %
     WRITE(A);
   END;
END;
END
