I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This     

Multiple Units

Multiple Units in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: Multiple   Multiple Units  
MerLiN
Australia
Can someone show me how to use multiple units in a project? I've written an app in Delphi 6 and I want to seperate the code to make it easier to edit. But I can't figure out how to use multiple units with only the one form.

Thanks for any help.

Merlin
http://kickme.to/merlin73
 Posted 17 years ago (Thread Starter)
Comment Quote
About MerLiN -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9053, 3 replies
Thread Started 2/14/2003 8:15:00 AM
View Counter=3606
Location=Australia  
Joined=18 years ago   MB Posts=13  
Rick Carter
Cincinnati OH USA
Study some of the sample projects that do this -- "Threads" might be a good one to look at.
Rick Carter
Chair, Delphi/Paradox SIG
Cincinnati PC Users Group
 Posted 17 years ago
Comment Quote
About Rick Carter -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9054 (Level 1.1)  Reply to 9053
Thread Started 2/14/2003 8:34:00 AM
View Counter=2
Location=Cincinnati OH USA  
Joined=19 years ago   MB Posts=518  
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
It's really just as simple as "File/New" and pick "Unit". That adds the unit file to your project, and you can move code into the new unit file.



The unit file has to be added to your form's Uses clause. Plus, if you have any classes in that unit, the form will have to create an object of that class (typically in the FormCreate method.



If you have component references in the code of the new unit file, then the form's unit file has to be included in the new unit's uses clause. This should be put in the implementation section, rather than the interface section. Just a warning...having two unit files include each other in the uses clause of their interface section will cause a circular reference error. Putting the files in the implementation section prevents this problem.



The threads project is a good one to study for unit usage between units.
 Posted 17 years ago
Comment Quote
About Scott Wehrly -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #9055 (Level 1.2)  Reply to 9053
Reply Posted 2/14/2003 9:09:00 AM
Location=Las Vegas, NV USA 
Joined=18 years ago   MB Posts=442   KB Posts=19  
Most Recent Post
Larry Drews
Iowa
Merlin,

Your main form unit makes use of other units by referencing them in a "uses clause". Check the Delphi Help for "uses clause" to get started understanding the relationships among units.
 Posted 17 years ago
Comment Quote
About Larry Drews -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Larry Drews
Veteran software developer specializing in Delphi/Kylix development. Currently Manager of Applications Development for a biotech company in Iowa.

Post ID #9056 (Level 1.3)  Reply to 9053
Reply Posted 2/14/2003 9:10:00 AM
Location=Iowa  
Joined=18 years ago   MB Posts=67   KB Comments=1  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1216A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #9053 Counter
3606
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech