having difficulty getting the unit to use an include file



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!

.



Relevant Pages

  • Re: UnRAROCX.ocx and unrar.dll
    ... FileName As String * 260 ... Private Type RAROpenArchiveData ... Private Declare Function RARCloseArchive Lib "unrar.dll" (ByVal hArcData As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem with passing parameter
    ... > 1) Your declare for WriteFile is incorrect. ... Since you're using strings you'd alias this API with an "A". ... > 2) You can *not* pass a variant, even if it's type is string, to an API ...
    (microsoft.public.vb.general.discussion)
  • Re: Problem with passing parameter
    ... Your declare for WriteFile is incorrect. ... Since you're using strings you'd alias this API with an "A". ... You can *not* pass a variant, even if it's type is string, to an API ... Public Sub WriteData ...
    (microsoft.public.vb.general.discussion)
  • Re: 2 Gig (roughly) file size limit -- NOT DBF RELATED
    ... declare Integer OpenFile in Win32API String, String, Integer ... > though FREAD() can read bytes from the file. ...
    (microsoft.public.fox.programmer.exchange)
  • can openxml write multiple fields - 1 row?
    ... I got an xml routine from the Sql Server NG where I can ... delimiters in the string. ... Declare @iDoc Int ...
    (microsoft.public.sqlserver.xml)