Yeah. I'm confused too.

Are the methods in your form unit, class methods, object methods or ordinary methods?

ie.
type
 TMyForm = class(TForm)
 public
    class procedure externalproc1(arg1,arg2,arg3....) //class method
    procedure externalproc2(arg1,arg2,arg3....) //object method
 end;

 procedure externalproc3(arg1,arg2,arg3....) //ordinary method

var
  MyForm : TMyForm;

To call externalproc1
TMyForm.externalproc1(arg1,arg2,arg3....) //use the class name

To call externalproc2
MyForm.externalproc2(arg1,arg2,arg3....)  //use the variable name

To call externalproc3
externalproc3(arg1,arg2,arg3....)

Personally I think you should only have the application autocreate one form (MainForm), so variable MyForm should be deleted.

Todd.


----- Original Message ----- From: "John Bird" <[EMAIL PROTECTED]>
To: "'NZ Borland Developers Group - Delphi List'" <[email protected]>
Sent: Thursday, November 24, 2005 2:28 AM
Subject: [DUG] calling procedures in other units


Here is something that puzzles me, and maybe I have missed something, or my
D5 compiler is inconsistent, or I am doing it wrong?

I have a group of external procedures in a code only unit (no form) and to
access them I just have the unit in the uses clause and then call in code by
name eg

   externalproc1(arg1,arg2,arg3....)

If the other unit has a form attached then I use the same uses syntax, but I
have to call it by

   frmOtherform.externalproc1(arg1,arg2,arg3...)

Except that I think I have also have found sometimes the compiler does seem
to figure out where the externalproc1 is and doesn't always require the
formname before the procedure.

All I was trying to do was call some code in an external unit which does
printing, and the only reason I have a form for that unit is that I plonked
the printdialog on it (it doesn't have anything else on the form) as it
seemed best to keep it with the printing code.  But it made calling the
printing routines more verbose. Is there a better way to do it?

John


_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/175 - Release Date: 18/11/2005



_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to