Hi,

I have been trying to make a hierarchical library of routines using class procs/funcs. 
However Delphi 5 doesn't like me doing this.
What I have tried to do is as follows (hope this makes sense.. only important bits 
included):

type
  Tmyclass1 = class
     class procedure DoIt;
  end;
  Tmyclass1class = class of Tmyclass1;
  Tmyclass2 = class
    class1:Tmyclass1class;
  end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Tmyclass1.doIt;   // <- no probs with using a class proc
 // Tmyclass2.class1.doIt; // *** Delphi compiler doesn't like me doing this: 
accessing a class func through a ref to a class.
end;

class procedure Tmyclass1.DoIt;
begin
  ShowMessage('Hello');
end;


The error Delphi gives is: method identifier expected. 
I can understand this (yes, I've read the help on it) but why?? 
I have tried numerous ways of getting this to work but had to resort one option....
I can work around this by simply having a class proc in Tmyclass2 that returns a 
Tmyclass1 class. 
eg. 

Tmyclass2 = class
    class function class1:TmyClass1class;
end;

class function Tmyclass2.class1: TmyClass1class;
begin
  Result := tmyclass1;
end;

Then I can happily use this syntax: 'Tmyclass2.class1.doIt;'
This seems a not-too-nice way of doing what I want.
Any suggestions? Or am I trying to make Delphi be another language? ;)

The other thing is: Is Delphi's optimiser smart enough to convert my 'class1'  
function in Tmyclass2 into a static reference? ie. am I going to have a performance 
hit because of trying to do this hierarchical library thing?

TIA,

Chris

---

Chris Milham
Software Developer
MedTech Software Ltd.
Level M, 48 Market Place, Viaduct Basin, Auckland
Ph. +649 3559666 Extn. 714, Fax +649 3774231
E-mail: [EMAIL PROTECTED]
Web: http://www.medtech-software.com


This e-mail and any attachments are intended only for the person to whom it is 
addressed and may contain privileged, proprietary, or other data protected from 
disclosure under applicable law. If you are not the addressee or the person 
responsible for delivering this to the addressee you are hereby notified that reading, 
copying or distributing this transmission is prohibited. If you have received this 
e-mail in error, please telephone us immediately and remove all copies of it from your 
system. Thank you for your co-operation. 

 <<Chris Milham.vcf>> 
BEGIN:VCARD
VERSION:2.1
N:Milham;Chris
FN:Chris Milham
ORG:MedTech Software Ltd.
TITLE:Software Developer
NOTE;ENCODING=QUOTED-PRINTABLE:=0D=0A
TEL;WORK;VOICE:+649 3559666 Extn. 714
TEL;WORK;FAX:+649 3774231
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Level M=0D=0A48 Market Place=0D=0AViaduct Basin;Auckland;;;New Zealand
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Level M=0D=0A48 Market Place=0D=0AViaduct Basin=0D=0AAuckland=0D=0ANew Zeala=
nd
URL;WORK:http://www.medtech-software.com
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
REV:20020619T032950Z
END:VCARD

Reply via email to