?
Solved

Delphi Programming question

Posted on 1997-09-23
4
Medium Priority
?
184 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

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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