Solved

Beginner : Easy question...

Posted on 1998-02-27
6
145 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now