Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Beginner : Easy question...

Posted on 1998-02-27
6
Medium Priority
?
152 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 40 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 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