Prob w/ Int64 in class, Delphi 5

From: Fafhrd (Fafhrd_at_sympatico.ca)
Date: 12/31/03


Date: 30 Dec 2003 22:51:13 -0700


Considering the (not stylish) code below:
-----------
interface

type
  Tbarr8 = packed array[0..7] of byte;

  TTF_datetime = class
   private
     Val : Int64;
   public
     Procedure Load(VAR F : TTF_File);
     ...
   end;

implementation

Procedure TTF_datetime.Load(VAR F : TTF_File);
 begin
   Read(F, Tbarr8(Val)[7], Tbarr8(Val)[6], <<-- Line 379
           Tbarr8(Val)[5], Tbarr8(Val)[4],
           Tbarr8(Val)[3], Tbarr8(Val)[2],
           Tbarr8(Val)[1], Tbarr8(Val)[0]);
 end;
-----------
Output: [Error] TTFtypes.pas(379): Constant object cannot be passed as var parameter
(msg is repeated 8 times, so it really applies to references to Val)

Why does the compiler complain (at the "Read" statement) that Val is a constant? Tried typecasting to a record instead of packed array, etc., and still getting the same result.

Exact same construct works with a longint (typecast to barr4), so what's different here? If I make TTF_datetime an object instead of a class, it works. It's not a problem with duplicate identifiers (at least not one that I could find, and I tried different names).

BTW, this is brute-force for reading a big-endian file. Anyone has a better approach?

Thx. And a happy new year to all!