Solved

Beginner : Easy question...

Posted on 1998-02-27
6
147 Views
Last Modified: 2010-04-06
HI,
    How do I get a dialog box to use a function from the main unit? If I put it in uses, it says circular something. If I put uses in the implementation, it doesn't recognise the function and gives me a syntax error. Help! Final year project.. Very important!
0
Comment
Question by:NikWhit
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1359862
Hi

If the main unit uses the dialog unit, then only one can be in the interface uses clause.  The other MUST be in the implementation uses clause.

It sounds like your main has "uses dialog" in the interface uses clause.  Try moving it to the implementation uses clause.  The dialog can have "uses main" in its interface uses clause.

If this doesn't work, try providing the parts of your code (in both units) that seem to be causing the problem.

Regards,
JB
0
 

Expert Comment

by:bijoyn
ID: 1359863
Hi !,

Try putting the function is a separate library module so that main as well as any other form can use it. This i think will be a neat way to do it too ???.

Bijoy
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1359864
JimBob,
     See if you can work out what's gone wrong. When I try to
compile it, it gives me a syntax error when I try to call the
Main function 'InsertText' from the docclsdg unit. It's odd
I have included main in 'uses', but it just chooses not to
read it! I appreciate your help...

unit Main;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Menus, StdCtrls;

type
  TMainForm = class(TForm)
    MainMenu1: TMainMenu;
   
   ..
   ..
   ..
   
         
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation
uses
    Docclsdg;
{$R *.DFM}

procedure TMainForm.RunLaTeX1Click(Sender: TObject);
begin
WinExec('Latex',SW_SHOWMAXIMIZED);
end;

procedure TMainForm.Class1Click(Sender: TObject);
begin
     docclassdlg.ShowModal;
end;

procedure TMainForm.InsertText(var S: string);
begin
     MainForm.EditPad.Lines.Add(S);
end;
end.



****************************************
unit Docclsdg;

interface

uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  StdCtrls, ExtCtrls, Main;

type
  Tdocclassdlg = class(TForm)
    OKBtn: TBitBtn;
    CancelBtn: TBitBtn;
    HelpBtn: TBitBtn;
    Bevel1: TBevel;
    RadioGroup1: TRadioGroup;
    Label1: TLabel;
    procedure OKBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  docclassdlg: Tdocclassdlg;

implementation

{$R *.DFM}

procedure Tdocclassdlg.OKBtnClick(Sender: TObject);
begin
     InsertText('Inserted Text');
end;

end.
0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
LVL 5

Expert Comment

by:JimBob091197
ID: 1359865
Hi

Try "MainForm.InsertText..."

JB
0
 
LVL 1

Author Comment

by:NikWhit
ID: 1359866
JimBob,
That Works! How stupid of me! How do I give the points to you?
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 10 total points
ID: 1359867
Hi

I have to answer the question (which I am doing now) before you can grade my answer (i.e. give me pts).

Regards,
JB
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question