Program Lee_Archivo_Binario;
Type
TProc = Procedure(Ch :Char);
PProc = ^TProc;
{Va leyendo un archivo binario Byte por Byte, llamado al procedimiento "Proc"}
{después de cada lectura. Le pasa como parámetro el caracter leído}
Procedure LeeBin(Arch :String; Var Proc :PProc);
Var
Ch :File;
Dt :Byte; {Almacena el Byte leído}
Ld :Word; {Cantidad de Bytes que se pudieron leer}
Begin
Assign(Ch, Arch);
Reset(Ch, 1);
Repeat
BlockRead(Ch, Dt, 1, Ld);
If (Ld=1) then Proc^(Chr(Dt));
Until (DosError>0) or (Ld=0);
Close(Ch);
End; {LeeBin}
{Despliega un caracter en pantalla}
Procedure MiProc(Ch :Char);
Begin
Write(Ch);
End; {MiProc}
Begin
LeeBin('C:\MIBIN.DAT', @MiProc);
ReadLn;
End. {Lee_Archivo_Binario}