Skip to content
/ duse Public

A little tool for Delphi programmer to find the possible unit scopes that a unit belongs to

License

Notifications You must be signed in to change notification settings

ddabapps/duse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

duse

A little tool for Delphi programmers to find the unit scope(s) that a unit belongs to.

Contents

Introduction

Since the introduction of unit scopes to Delphi I've been struggling to remember the names of the unit scopes that some units belong to. OK, sometimes the code editor will pop up a list of units in a unit scope, but what I want is to type in a unit name and be told what unit scopes(s) the unit may belong to. Hence DUSE.

And the name? Delphi Unit Scope Expander.

Installation, Updating & Removal

Installation

DUSE is available as both 64 bit and 32 bit Windows applications. You should always use the 64 bit version if you're running 64 bit Windows and only use the 32 bit version if you're running 32 bit Windows.

The 64 and 32 bit versions are distributed in separate zip files named duse-64bit-<version>.zip and duse-32bit-<version>.zip respectively, where <version> is the release version number. Download the appropriate version from the Releases tab on GitHub and unzip the file.

The 64 bit program is named DUSE.exe while the 32 bit program is named DUSE32.exe. There is no installer. You simply need to copy the appropriate .exe file to a folder on your computer or on a USB drive. You can copy this README.md file to the same location if you wish.

When it is first run, DUSE will write data to a config sub-directory of whichever folder you put it in. For that reason you may prefer to place the program in its own folder.

DO NOT place DUSE in your system's program files folder since the system will probably prevent it from writing the necessary data files.

Updating

To update the program simply download a newer version and overwrite the appropriate .exe file in whichever location you installed it. Be careful not to delete the config subdirectory otherwise you will loose your data.

🗒️ If you are updating from v0.2.1-beta or earlier then the existing file name will be either Unit2NS64.exe (64 bit) or Unit2NS32.exe (32 bit). Delete that file and copy in either DUSE.exe or DUSE32.exe in its place. It remains important to preserve the config sub-directory and its content.

Removing

To uninstall the program simply delete the .exe file from wherever you installed it. If you have no further use for the program's data then delete the config sub-directory and all its contents too.

Mini-help

DUSE is in very early beta, and there's no proper help system as yet. So this is all you get right now!

Getting started

DUSE uses what it calls "mappings" to look up the names of unit scopes that a given unit may belong to. The idea is you can have different mappings for different versions of Delphi. So, before you can start using it you need to create at least one mapping.

To do this, start the program and click the New Mapping button. In the resulting dialogue box the first thing to do is to give the mapping a sensible name.

Now you need to provide it with a list of unit scopes and the units that belong to them. There are four ways to do this at present:

  1. The long winded way is to enter a fully specified unit name (e.g. System.SysUtils) in the edit box above the Add button, then click Add. Keep doing this until you've entered all the units you need. Tedious huh?

  2. A much easier method is to choose the Read Units From Source Folder button. This opens a dialogue box where you choose a directory containing some Pascal source code. Selecting a folder causes every Pascal unit in that folder, and all it's sub-folders, to be read into the mapping. So, if you choose your version of Delphi's source folder you'll load every unit Delphi provides into your new mapping. You'll get quite a few units you probably don't want, but that's not really a problem. You can delete any units you don't want by selecting them in the list and clicking the Delete button.

  3. Closely related to the previous option is to choose the Read Units From DCU Folder button. This allows you to choose a directory containing .dcu files instead of .pas files.

  4. If you have one or more versions of Delphi installed that support unit scopes (i.e. Delphi XE2 & later) you can just click the Read Units From Delphi Installation button. This displays a list of all supported installed versions of Delphi in a dialogue box. Choose an installation and click OK. The units from that version of Delphi's source directory will be loaded into your new mapping without you having to locate them.

Once you're done click the Save And Close button to save the mapping.

The new mapping will appear in the Mappings drop down at the top of the main window, along with any others you've created. All mappings are saved in the config folder alongside the executable program and are loaded automatically the next time you start DUSE.

General use

When you need to know what unit scope a unit belongs to, enter the unit's name in the Name of unit edit box in the main window. Click Find unit scope(s) (or press Ctrl+U) and the names of any unit scopes containing a unit of that name will appear in the list box below. Selecting the unit scope name you want then clicking Copy Full Name (or pressing Ctrl+C) puts the fully specified unit name on the clipboard ready for pasting into your code.

You will sometimes see a unit scope named <no unit scope>. That's just a dummy that indicates that the unit exists outside any unit scope. When the <no unit scope> is selected clicking Copy Full Name simply puts the unqualified unit name on the clipboard.

There's another little feature you might find useful if Delphi's code editor doesn't feel like showing you all the units belonging to a unit scope. In the Lookup units in unit scope box you can select the name of any unit scope from the Choose unit scope drop down to reveal all its units in the list below. Selecting <no unit scope> reveals all the units that exist outside any unit scope.

You can create new mappings, edit them or delete them whenever you wish. The buttons to do that are pretty self-explanatory!

You can't rename a mapping.

License

DUSE is copyright © 2021-2023, Peter Johnson (delphidabbler.com) and is released under the MIT license. See the LICENSE file included in the root of the GitHub repository for details.

Changelog

See the file CHANGELOG.md in the root of the GitHub repository for details of releases and changes.

Contributing

Contributions are welcome. The source code is in the ddabapps/duse project on GitHub.

I'm using the Git Flow methodology.

Please make a fork from the develop branch (not master) and create a new feature branch† for your code. When ready please submit a pull request.

† Feature branches should be named in the form feature/my-feature-name. If you're fixing/implementing an issue then please prepend the issue number to the branch name like this feature/#99-abbreviated-issue-name.

Compiling From Source

DUSE is written in Delphi Object Pascal and developed using Delphi 11 Alexandria (Delphi 10.4.1 Sydney was used for v0.1.0-beta). The program can be compiled from within the IDE.

Bugs and Feature Requests

It's early days yet, so bugs are likely. Bug reports are welcomed. Please use the GitHub project's Issues feature to do that. Bug fixes are even more welcome!

You can also request new features. I want to keep this little app simple, but I can see several ways in which it can be improved, so don't hesitate to suggest something.