Link to home
Start Free TrialLog in
Avatar of Dave_B_C
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(Sender: TObject);

begin
     
      button:=MessageDlg('Write File?',mtConfirmation,[MbYes,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.
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

you might try to change the


TForm3.Write_File;


to


Form3.Write_File;
ASKER CERTIFIED SOLUTION
Avatar of Dumani
Dumani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dave_B_C
Dave_B_C

ASKER

Nice one Dumani, thanks.!Also thanks to Slick who was on the right track!

Dave