I have a code to read a file and write a file on the screen, but on some textfiles it stops to early with writing, and when I later in the progam progress the file it is not completely progressed is there a way to entirely progres the file
[code]
var fileloc : string;
textfile : text;
temp : char;
begin
readln(fileloc);
assign(textfile, fileloc);
reset(textfile);
while not eof(textfile) do
begin
read(textfile, temp);
write(temp)
end;
end.
[/code]
Comments
you have to close the file after processing.
: I have a code to read a file and write a file on the screen, but on some textfiles it stops to early with writing, and when I later in the progam progress the file it is not completely progressed is there a way to entirely progres the file
:
: [code]
: var fileloc : string;
: textfile : text;
: temp : char;
:
: begin
: readln(fileloc);
: assign(textfile, fileloc);
: reset(textfile);
: while not eof(textfile) do
: begin
: read(textfile, temp);
: write(temp)
: end;
: end.
: [/code]
:
: you have to close the file after processing.
:
: : I have a code to read a file and write a file on the screen, but on some textfiles it stops to early with writing, and when I later in the progam progress the file it is not completely progressed is there a way to entirely progres the file
: :
: : [code]
: : var fileloc : string;
: : textfile : text;
: : temp : char;
: :
: : begin
: : readln(fileloc);
: : assign(textfile, fileloc);
: : reset(textfile);
: : while not eof(textfile) do
: : begin
: : read(textfile, temp);
: : write(temp)
: : end;
: : end.
: : [/code]
: :
:
:
yes i know that i have done it already, this is just a part of the entire code, the problem is not fixed with that.
the code is to encode and decode files, it only happens with coded files.
: : you have to close the file after processing.
: :
: : : I have a code to read a file and write a file on the screen, but on some textfiles it stops to early with writing, and when I later in the progam progress the file it is not completely progressed is there a way to entirely progres the file
: : :
: : : [code]
: : : var fileloc : string;
: : : textfile : text;
: : : temp : char;
: : :
: : : begin
: : : readln(fileloc);
: : : assign(textfile, fileloc);
: : : reset(textfile);
: : : while not eof(textfile) do
: : : begin
: : : read(textfile, temp);
: : : write(temp)
: : : end;
: : : end.
: : : [/code]
: : :
: :
: :
: yes i know that i have done it already, this is just a part of the entire code, the problem is not fixed with that.
: the code is to encode and decode files, it only happens with coded files.
:
Then the coded files contain the end-of-file symbol before the actual eof. I would suggest an alternate method of loading using a file of char:
[code]
var
f: file of char;
ch: char;
FileLength, i: integer;
begin
Assign(f, fileloc);
Reset(f);
FileLength := FileSize(f);
for i := 0 to FileLength-1 do
begin
read(f, temp);
write(temp)
end;
Close(f);
end;
[/code]
This should read the entire file and display it on the screen.