Board index » delphi » text-/binary files

text-/binary files

Hello,

is it possible to open a file as an binary-file, position the filepointer
and than use it as an text-file? Or is there another possibility to
position the filepointer in a text-file?

Hope somebody could help me.

--
Michael Bialas                  e-Mail: mich...@quinto.ruhr.de

 

Re:text-/binary files


Quote
Michael Bialas <mich...@quinto.ruhr.de> wrote:
>is it possible to open a file as an binary-file, position the filepointer
>and than use it as an text-file? Or is there another possibility to
>position the filepointer in a text-file?

I don't think you can fool Delphi to accept "mixed" file reading, but
you can easily set the file pointer, for example like this:

Uses SysUtils,Windows;
...
Var
  F : Text;
...
SetFilePointer(TTextRec(F).Handle,100,nil,File_Begin);

HTH.

Regards,

Jani J?rvinen
a.k.a SilverStream Software
Helsinki Finland

Tools, information, tips, reviews & bug lists
for professional Delphi, Win32 and WinHelp developers.

mailto:ja...@dystopia.fi
http://www.dystopia.fi/~janij/

Re:text-/binary files


Completely possible, if you just treat the binary-file as the
textfile like that:

Var f:file of {Whatever type u want to assign for the record in file}

begin
  read(f,{something});
  write(f,{something});
  seek(f,{pointeroffile});
end;

Quote
Michael Bialas wrote:

> Hello,

> is it possible to open a file as an binary-file, position the filepointer
> and than use it as an text-file? Or is there another possibility to
> position the filepointer in a text-file?

> Hope somebody could help me.

> --
> Michael Bialas                  e-Mail: mich...@quinto.ruhr.de

Other Threads