:
This message was edited by Hav0c #1 at 2006-2-8 7:3:27
: : : : : Hi all
: : : : : I have an question what does Incompatible types: 'TPersistent' and 'TMembersRec' mean ?
: : : : : i get the message at line regOutput.lines.Assign(OneRec);
: : : : :
: : : : :
: : : : : {===================================================================}
: : : : : type
: : : : : TMembersRec = Record
: : : : : Initials : string[4];
: : : : : Surname : string[30];
: : : : : Adult : boolean;
: : : : : Balance : Real;
: : : : : end;
: : : : : var
: : : : : Members : TMembersRec;
: : : : : {===================================================================}
: : : : :
: : : : : procedure TfrmQ1.bmbOKClick(Sender: TObject);
: : : : : var
: : : : : DataFile : file of TMembersRec ;
: : : : : OneRec : TMembersRec ;
: : : : : begin
: : : : : case rgpChoices.ItemIndex of
: : : : : -1 : begin
: : : : : MessageDlg('Choice a option from Manu please',mtInformation,[mbOK],0);
: : : : : end;
: : : : : 0 : begin
: : : : : AssignFile(DataFile,'D:\Delphi 7\Projects\vraag 1 van eksamen\ledeD.dat');
: : : : : reset(DataFile);
: : : : : WHILE not eof(DataFile) DO
: : : : : BEGIN
: : : : : read(DataFile,OneRec);
: : : : : regOutput.lines.Assign(OneRec);
: : : : : END;
: : : : : end;
: : : : : end;
: : : : :
: : : : : end;
: : : : : end.
: : : : :
: : : : :
: : : : It means that OneRec isn't an object of the TPersistent class or one of its descendants. The solution is either to change the type of OneRec into one of the TPersistent descendants, or to change the assignment from a call to Assign() to a more compatible code.
: : : :
: : :
: : : ok now how do I do that
: : : can u give me examples of both how to do both please
: : : u see the file contains a list of club members with there info
: : : what is TPersistent class can u give me examples please
: :
:
: :
: :: Either way, you attempt to Assign a OneRec to a TStrings (regOutput.lines.Assign(OneRec)). Whatever you do to fix it, this is still not possible then. What you (probably) could do is regOutput.lines.Add(OneRec.SurName
:
:
:
: regOutput.lines.Add(OneRec.SurName) works if u only want the SurName in regOutput
: but the question is how do I get it in this format
:
: ex
:
: Initials Surname Adult Balance
:
: A bdbd Yes $15264
:
:
:
:
:
You can use the Format() function for that:
with OneRec do
if Adult then
regOutput.lines.Add(Format('%s'#9'%s'#9'Yes'#9'%f', [Initials, SurName, Balance]);