awmross
awmross

Reputation: 3839

Does a separate .exe always require a separate project in Delphi?

Our application requires quite a few tools and utilities we have written to support our product. Things like data converters, backup utilities etc. Currently, each of these utilities is a separate Delphi Project. On top of that, many of these projects also have a corresponding DUnit project for unit testing, which also have to be a separate project. We currently have 13 separate Delphi projects. These projects are all in one Project Group.

Is this necessary? Do we have to have so many separate projects, or is there a way in Delphi to have multiple entry points into the same project?

Also, sometimes it would be convenient during development to just write some code and 'run' it. To do this now I end up hacking the project file; commenting out the normal behaviour and replacing it with the code I want to run. Is this the only way?

We use Delphi 2010 if that makes a difference.

Upvotes: 2

Views: 414

Answers (3)

jszpilewski
jszpilewski

Reputation: 1632

As it was already mentioned you can convert mini projects into units. Then use compile conditionals ($ifdef etc.) to select which unit is being included in the compiled program. It would be also handy to be able to automatically switch the name of the generated executable file. I think it would be possible to create a relatively simple OTA (Open Tools API) plugin that could control all those features.

To run small parts of code you can create a separate lightweight console project where you can paste the code to the main function.

Upvotes: 1

Ken White
Ken White

Reputation: 125728

You can do either of these pretty easily:

  • Combine your projects into a project group, to be able to work with them together more easily.

  • (My preference) Separate your projects into different units (instead of project files), create a single application that uses all those units, and call different functionality based on command-line parameters (see ParamCount and ParamStr in the documentation) You can then easily write unit tests by testing each of the units (pun not intended) separately.

Regarding your edit: Delphi is a compiled, not interpreted, language. You can't just "run" code without compiling it, unless you can use functionality that's in your app using the Evaluate/Modify menu item during debugging. (Set a breakpoint and run your app. When it hits the breakpoint, use Ctrl+F7 to open the Evaluate/Modify dialog. Note that this has limited functionality due to the nature of the optimizer and compiler.

Upvotes: 5

Antonio Bakula
Antonio Bakula

Reputation: 20693

Organize your project in one or more Project Groups, and you could use project (exe) parameters to execute just some part of your exe.

Upvotes: 1

Related Questions