Solved

Delphi Programming question

Posted on 1997-09-23
4
183 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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
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 …

726 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