Re: having difficulty getting the unit to use an include file
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 17:00:51 -0500
Adam Sandler wrote:
But first, here's the contents of my include file:
type mailingListRecord = record givenName : string; familyName : string; address : string; city : string; state : string; postalCode : Integer; end;
OK. Note that the file contains a type declaration. A type declaration. Remember that for later.
And here's the unit file:
unit IncludeExample;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
{$I RecordExample.inc}
If it would help you, just copy the contents of RecordExample.inc and paste them into this file, in place of the $I directive. That's all the compiler does, after all. Seeing the text of your unit the same as the compiler sees it might help you notice the error.
type TForm1 = class(TForm) myMemo: TMemo; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
So the interface section of the IncludeExample unit contains three things: A record-type declaration for mailingListRecord, a class-type declaration for TForm1, and a variable declaration for Form1.
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin mailingListRecord.givenName := 'joe';
You can't assign values to types. Remember what mailingListRecord is?
myMemo.Lines.Clear; myMemo.Lines.Add(mailingListRecord.givenName); end;
end.
At first I though the problem was because I didn't declare the record. But that wasn't it because if I put mailingListRecord : TMailingListRecord; in the interface section, I get a identifier redeclared error.
Of course. You've already declared "mailingListRecord" to be the name of a type. I have no idea what "TMailingListRecord" is, and neither does the compiler.
When I try to send text to any of the strings declared in the record, I get an error stating object or class type required.
Yep.
-- Rob .
- Follow-Ups:
- Re: having difficulty getting the unit to use an include file
- From: Adam Sandler
- Re: having difficulty getting the unit to use an include file
- From: Adam Sandler
- Re: having difficulty getting the unit to use an include file
- References:
- having difficulty getting the unit to use an include file
- From: Adam Sandler
- having difficulty getting the unit to use an include file
- Prev by Date: having difficulty getting the unit to use an include file
- Next by Date: Re: having difficulty getting the unit to use an include file
- Previous by thread: having difficulty getting the unit to use an include file
- Next by thread: Re: having difficulty getting the unit to use an include file
- Index(es):
Relevant Pages
|