
Originally Posted by
bullzeye95
Yes, you are using it completely wrong. The function reads a binary file, not a text file. What you're doing is squishing a string into an integer. If you want to be able to read integers from it, you must first put them into the file by using WriteFileInt.
Or you could combine ReadFileString with StrToInt if you really wanted to use a regular text file. You'd use it like this in your original code if you wanted to:
SCAR Code:
{i is already defined as: var i: integer;}
{open is defined as: var open: boolean;}
begin
filenum := OpenFile('C:\--------------------\cbcountercount.txt', false);
open := ReadFileString(filenum, j, FileSize(filenum));//note that j would have to first be declared as a string
if (open)then
begin
i := StrToInt(j);
writeln(filenum);
writeln('Sucess in openning file!');
writeln(inttostr(i));
end;