CodeSnip Code Snippets Repository
|Date:||25 September 2014|
|O/S:||Windows 2000 and later|
CodeSnip is an open source code bank for storing and viewing code snippets. It not only manages, displays and manipulates your own code snippets but it can also incorporate snippets downloaded from the online Code Snippets database.
Snippets can be displayed by category, alphabetically or by type. Full details of a selected snippet are displayed [see screenshot 2].
Designed with Pascal in mind, CodeSnip enables Delphi or Free Pascal code snippets to be test-compiled with any installed version of those compilers. Results are reported as shown in [see screenshot 4]. Use this feature to validate the syntax of code without having start your compiler's IDE.
Code in other languages can be stored in CodeSnip although the source file generation and compiler checking features will not be available.
The database can be searched for snippets that contain specified text, for cross referenced snippets. The snippets to be displayed can also be selected manually. In addition you can search for Pascal snippets that compile under given versions of Delphi or Free Pascal.
Frequently used snippets can be marked as "favourites" for quick access.
CodeSnip can generate and export Pascal source code in various ways:
- Compilable Object Pascal units containing selected snippets from the database can be generated and written to file.
- Individual routines or whole categories can be written to Object Pascal include files or copied to the clipboard for including in Delphi and FreePascal projects.
- Information about snippets can copied or printed.
- Selected snippets can be exported to files that can be shared with other CodeSnip users.
Units and Pascal include files can also be exported as syntax highlighted XHTML or rich text files. The Pascal syntax highlighter can be customized.
Finally CodeSnip comes in two editions. More information.
Updating the Database
The online DelphiDabbler Code Snippets database is not installed with the program. However, if an older installation is present setup will give the option to carry it forward if possible. When setup completes it checks for the presence of the database and puts up a message if it is not present.
CodeSnip's start-up screen shows details of any installed databases. If there is no copy of the online database a link is displayed that enables the database to be installed.
By default CodeSnip (v4.4.0 and later) will check for database updates about once per week. When an update is detected a notification window will appear in the bottom right of the main window. You can click a button here to display the Update From Web dialogue box which you use the update your database.
If you don't want this automatic checking, or if you would like to change the frequency with which checks are made, you can change the settings by using the Updates tab of the Preferences dialogue box. This dialogue is displayed from the Tools | Preferences menu option.
If you have switched off CodeSnip's automatic update checking you can check manually by displaying the Update From Web dialogue box from the Database | Update From Web menu option.
Database updates will apply to all users of the computer.
Note that CodeSnip v1 and v2 do not receive database updates: these were frozen on 30 September 2013.
Configuring CodeSnip to Work With Your Compilers
A feature of CodeSnip is its ability to test compile snippets with any installed Windows 32 version of Delphi and FreePascal. User defined snippets can also be test compiled providing some simple rules are followed.
When CodeSnip is first installed it knows nothing about the available compilers and so test compilations cannot be performed. You must tell CodeSnip about the available compilers by using the Tools | Configure Compilers menu option. The resulting dialogue box can automatically detect all installed versions of supported Delphi compilers at the click of a button. Free Pascal, where installed, must be set up manually. The Welcome page displays a list of compilers it has been configured to work with.
Compilers that do not use English as their output language will need further configuration. See the help file for information (look up "configure compilers dialogue" in the help file index).
There are a couple of ways to get news about changes to this program and to the online database:
- Subscribe to the Code Snippets News Feed to get news of changes delivered to your news reader or browser.
- Every time you update the database from CodeSnip the latest news is displayed in the Update From Web dialog box.
Each user can configure compilers differently.
Delphi XE2 to XE5 may need to be configured to search for required units in the correct namespaces. This is explained in the "Add/Edit Snippet Dialogue Box" help topic and in the FAQ.
The DelphiDabbler wiki has a FAQ that answers questions about using CodeSnip.
Suggestions for new features are always welcome – please use the Feature Request Tracker on SourceForge to submit feature requests.
Because CodeSnip is open source you can download the source code and make modifications yourself. If you create any useful new features please advise me so that I can consider incorporating the changes into CodeSnip.
Known bugs and fixes are maintained by the CodeSnip Bug Tracker on SourceForge.
CodeSnip will automatically detect bugs that raise unexpected exceptions and will display a bug report dialogue box. Any other bugs can be reported by selecting the Tools | Report Bug Online menu option. In either case you will be taken to the bug tracker. Please provide as much information as you can about the bug – I can't fix it without a comprehensive description.
Do not report bugs in CodeSnip v3 or earlier: these versions are no longer supported.
Source code of some tests for selected snippets from the database is available as part of the Delphi Doodlings repository on Assembla.com. The code can be found in the CodeSnippets sub-directory of the trunk.