Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Incompatible types Posted by Hav0c #1 on 8 Feb 2006 at 5:39 AM
This message was edited by Hav0c #1 at 2006-2-8 5:43:44

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.

[\code]



Report
Re: Incompatible types Posted by zibadian on 8 Feb 2006 at 5:54 AM
: This message was edited by Hav0c #1 at 2006-2-8 5:43:44

: 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.
Report
Re: Incompatible types Posted by Hav0c #1 on 8 Feb 2006 at 6:11 AM
: : This message was edited by Hav0c #1 at 2006-2-8 5:43:44

: : 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



Report
Re: Incompatible types Posted by pritaeas on 8 Feb 2006 at 6:42 AM
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)

: : : This message was edited by Hav0c #1 at 2006-2-8 5:43:44

: : : 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
:
:
:
:

Report
Re: Incompatible types Posted by Hav0c #1 on 8 Feb 2006 at 7:02 AM
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




Report
Re: Incompatible types Posted by zibadian on 8 Feb 2006 at 8:24 AM
: 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]);




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.