The code snippet below demonstrates a problem I am having with with text IO and UInt64 type variables in Delphi XE2 recently re-installed from a recent ISO image file - the compile fails with an error message relating to a missing Text.ReadUInt64 function or procedure. If I replace the failing line with
ReadLn(F,A);
then the program compiles, correctly writes
-1
18446744073709551615
to the text file, and then (as expected) fails on the second read with an EInOutError: "Invalid Numeric Input". Do I have a corrupt install or has someone failed to write a ReadUInt64 function? The only reference to ReadUInt64 that I can find in help is the following definition:
function ReadUInt64: UInt64; virtual;
in System.Classes.TBinaryReader.ReadUInt64. I'm not sure if this is the 'same' function or, if so, why it is virtual...
I am also a little confused by Help's reference to UInt64. It defines it as:
type UInt64 = Int64;
If this is correct, how does the compiler know to treat an UInt64 differently to an Int64 variable?
procedure TForm1.Button1Click(Sender: TObject);
var
F : TextFile;
A : Int64;
B : Uint64;
begin
{
Compiler warns on following line with message:
[DCC Warning] Unit1.pas(32): W1012 Constant expression violates subrange bounds
}
A := $FFFFFFFFFFFFFFFF;
B := $FFFFFFFFFFFFFFFF;
AssignFile(F,'test.txt');
ReWrite(F);
Writeln(F,A);
Writeln(F,B);
CloseFile(F);
AssignFile(F,'test.txt');
ReSet(F);
ReadLn(F,A);
{
Fails to compile on following line with message:
[DCC Fatal Error] Unit1.pas(42): E2158 System unit out of date or corrupted: missing 'Text.ReadUInt64'
}
ReadLn(F,B);
CloseFile(F);
end;