Thanks Dennis, that's what I ended up doing. I just thought I was, um, you
know, cheating (eyes dart around the DUG virtual room at the experienced OO
coders sitting in the jury box).
Wayne
-----Original Message-----
From: Dennis Chuah [mailto:[EMAIL PROTECTED]]
Sent: Monday, 9 July 2001 10:44
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Can I read an object where a record worked?
Wayne,
Create an object to wrap around your record.
TMyRecordType = record
field1: array[1..3] of char;
field2: array[1..175] of char;
end;
TMyClassType = class
private
Frec: TMyRecordType;
// Get and set methods for fields in Frec
public
constructor Create (Filename: string);
procedure ReadRecord;
procedure WriteRecord;
property Field1: string read GetField1 write SetField1;
property Field2: string read GetField2 write SetField2;
end;
Regards,
Dennis.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, 9 July 2001 09:05
> To: Multiple recipients of list delphi
> Subject: [DUG]: Can I read an object where a record worked?
>
>
> I have been reading fixed length records from a file using:
> Read(AFileName, ARecordName);
>
> I wanted to convert the record to a class so it could have methods so I
> changed the definition from something like:
> TMyRecordType = record
> field1: array[1..3] of char;
> field2: array[1..175] of char;
> end;
>
> to:
>
> TMyRecordType = class
> //I might have put 'private' here
> field1: array[1..3] of char;
> field2: array[1..175] of char;
> end;
>
> At this point, Read(AFileName, ARecordName) didn't seem to cause any
> problems, except that it field1 is always [#0, #0, #0] and field
> 2 similarly
> empty. Am I on the wrong track?
>
> Wayne
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"