having difficulty getting the unit to use an include file
- From: "Adam Sandler" <corn29@xxxxxxxxxx>
- Date: 29 Aug 2005 14:41:46 -0700
Hello,
I've searched this group for info about include files but mostly found
debate on why someone would want to use them. I see value in include
files as code templates and was wondering if anyone could show me where
I'm going wrong. Just as a simple test, I have a memo object on a form
and I want to send text to it.
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;
And here's the unit file:
unit IncludeExample;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;
{$I RecordExample.inc}
type
TForm1 = class(TForm)
myMemo: TMemo;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
mailingListRecord.givenName := 'joe';
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. 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.
I don't get it, if I try to declare the object, I get an error stating
I'm redeclaring something existing. But if I try to use the object
from the include file, the compiler tells be I didn't declare it. I'm
messing up big somewhere, I just don't know where.
Suggestions are greatly appreciated.
Thanks!
.
- Follow-Ups:
- Re: having difficulty getting the unit to use an include file
- From: alanglloyd@xxxxxxx
- Re: having difficulty getting the unit to use an include file
- From: pr
- Re: having difficulty getting the unit to use an include file
- From: Rob Kennedy
- Re: having difficulty getting the unit to use an include file
- Prev by Date: Re: HTTPS using Indy
- Next by Date: Re: having difficulty getting the unit to use an include file
- Previous by thread: HTTPS using Indy
- Next by thread: Re: having difficulty getting the unit to use an include file
- Index(es):
Relevant Pages
|