Solved

Beginner : Easy question...

Posted on 1998-02-27
6
150 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

751 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