Solved

Delphi Programming question

Posted on 1997-09-23
4
181 Views
Last Modified: 2010-04-04
This one is probably simpler than I am making it, but I am adding a new form to an existing project, but I want the new form to call procedures in the old form.  If the new form is called "formnew" and the existing form is called formexist, Is there a way I can access formexists procedures from the new form, formnew?  I don't want to add duplicate code in the "formnew".  (I know I can have a separate pascal unit and just include it in both forms uses clause, but I don't want to do that). What is the easiest way of doing this, or is there a way I can do this? (I may be totally missing the boat on this one, so even pointing me in the right direction would be helpful).
0
Comment
Question by:jexd99
[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
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
jturpin earned 0 total points
ID: 1346062
You pretty well have to put the unit in your uses clause.

However, the best way is to put the name of the FormExist
unit in the implementation section of the FormNew unit.

e.g.

.
.
Implementation

      uses
         FormExistUnit;


If you really don't want to do this, for some reason,
try and pull the routines you want out of FormExist
and put them in a seperate unit. Then put this unit
in the uses statement under Implementation in
both FormExist, and FormNew.

John.
0
 

Author Comment

by:jexd99
ID: 1346063
I probably didn't explain this quite right, but the first part that you mention above is exactly what I want to do, and the second part (putting the same unit in each uses) is what I want to avoid.
Everytime I try placing the formexist unit in the formnew uses clause, and then I have one line in formnew which calls a proc in formexist, the compiler doesn't recognize the proc name?

i.e.
formexist {this is the main form}
  .
  .
procedure test;
----------------
formnew   { new form added to formexist }
uses
   formexistunit

Now if I call "test" here, the compiler doesn't recognize this.
Can this be done this way?
-----------------
Thanks
(If necessary, I may have to just pull the code out as a separate unit, then add the unit to each form as you mentioned in step 2.)
0
 
LVL 1

Expert Comment

by:jturpin
ID: 1346064
Is your procedure defined as:
#1)   procedure Test;
or
#2)   procedure TFormExist.Test;

If it is defined as #1 then you need to declare Test
in the interface section of FormExist like:
   Interface
   .
   .
      Procedure Test;
   .
   Implementation


If it defined as #2 then you need to ensure that the routine
is not in the private section, and not in the protected
section of FormExist.
   FormExist = class(TForm);
     .
     {Here maybe}
     .
   private
     procedure Test; {NOT HERE}
   protected
     {NOT HERE}
   public
     {Here maybe}
   end;

ok.

John.
0
 

Author Comment

by:jexd99
ID: 1346065
Thanks for the info on this. I appreciate it. :)
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 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