var myFile : File; byteArray : array[1..8] of byte; oneByte : byte; i : Integer; myWord, myWord1, myWord2 : Word; myFileW : File of Word; begin // Try to open the Test.byt file for writing to Assign(myFile, 'File.001'); Rewrite(myFile, 4); // Define a single 'record' as 4 bytes // Fill out the data array for i := 1 to 8 do byteArray[i] := i; // Write the data array to the file BlockWrite(myFile, byteArray, 2); // Write 2 'records' of 4 bytes // Close the file Close(myFile); // Reopen the file for reading Reset(myFile, 1); // Now we define one record as 1 byte // Display the file contents while not Eof(myFile) do begin BlockRead(myFile, oneByte, 1); // Read and display one byte at a time Writeln(oneByte); end; // Close the file for the last time Close(myFile); // Try to open the Test.bin binary file for writing to Assign(myFileW, 'File.002'); Rewrite(myFileW); // Write a couple of lines of Word data to the file myWord1 := 234; myWord2 := 567; Write(myFileW, myWord1, myWord2); // Close the file Close(myFileW); // Reopen the file in read only mode Reset(myFileW); // Display the file contents while not Eof(myFileW) do begin Read(myFileW, myWord); Writeln(myWord); end; // Close the file for the last time Close(myFileW); end.