smargari@nmsu.edu (Susan Margarit) (01/31/91)
I cannot get Think Pascal 3.01 to compile this code segment and I'm
not sure why. Anybody have any ideas? I'm tired of staring at it.
unit DontCompile;
interface
implementation
type
DestinationType = record
key: packed array[1..10] of char;
{ actually used to store longint or chars }
datum: longint;
end;
procedure PutLongIntoChars (source: ptr; var dest: DestinationType);
{Stick the data pointed to by source into the 'key' field of
item.}
{Used to put a longint into a packed array[1..10] of char.}
type
LongPtr = ^Longint;
var
aLongPtr: LongPtr;
begin
aLongPtr := LongPtr(@dest.key); { this is the long way of sticking }
aLongPtr^ := LongPtr(source)^; {a longint into item.key }
LongPtr(source)^ := LongPtr(@dest.key)^;
{ this compiles but is the reverse of what I want }
LongPtr(@dest.key)^ := LongPtr(source)^;
{ this does not compile! }
end;
end.
Let me know if you have any ideas.
Jim.