Dave_B_C
asked on
Calling Procedures
I am trying to call a procedure in another .pas file.
However it does not compile with a message that 'this form of method call only allowed for class methods'. What am I doing wrong? Relevant code from the 2 modules below...
Cheers,
Dave
Unit GRUnit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, DB, ADODB, Grids, DBGrids, DBCtrls, Mask, GRUnit3;
type
TForm2 = class(TForm)
StatusBar: TStatusBar;
procedure Main_Process_Loop(Sender: TObject);
end;
var
Button: integer;
implementation
{$R *.dfm}
procedure TForm2.Main_Process_Loop(S ender: TObject);
begin
button:=MessageDlg('Write File?',mtConfirmation,[MbY es,MbNo],0 );
if button = mrYes then begin
TForm3.Write_File; {Writes output}
showmessage('File written');
end;
end;
end.
unit GRUnit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, DBCtrls, DB, Grids, DBGrids, ADODB, ExtCtrls;
type
TForm3 = class(TForm)
Procedure Write_File;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
Procedure TForm3.Write_File;
begin;
showmessage('Start');
end;
end.
However it does not compile with a message that 'this form of method call only allowed for class methods'. What am I doing wrong? Relevant code from the 2 modules below...
Cheers,
Dave
Unit GRUnit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls, DB, ADODB, Grids, DBGrids, DBCtrls, Mask, GRUnit3;
type
TForm2 = class(TForm)
StatusBar: TStatusBar;
procedure Main_Process_Loop(Sender: TObject);
end;
var
Button: integer;
implementation
{$R *.dfm}
procedure TForm2.Main_Process_Loop(S
begin
button:=MessageDlg('Write File?',mtConfirmation,[MbY
if button = mrYes then begin
TForm3.Write_File; {Writes output}
showmessage('File written');
end;
end;
end.
unit GRUnit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Mask, DBCtrls, DB, Grids, DBGrids, ADODB, ExtCtrls;
type
TForm3 = class(TForm)
Procedure Write_File;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
Procedure TForm3.Write_File;
begin;
showmessage('Start');
end;
end.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nice one Dumani, thanks.!Also thanks to Slick who was on the right track!
Dave
Dave
TForm3.Write_File;
to
Form3.Write_File;