Solved

Beginner : Easy question...

Posted on 1998-02-27
6
151 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

624 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