With the code librarian you can store snippets of code, for use in your programs. You can:
- Organize the snippets of code using categories and sub categories utilizing the tree-like view.
- Share code between your group.
Starting from version 4, OptiPerl uses a standard ZIP format to store all code snippets. Actually code snippets represent files in the zip archive. However the extracting and packing is so integrated, it does not look like an actual zip file is being used!
When you select a code snippet in the tree structure (that actually is folders and subfolders in the archive), it is extracted and displayed in the editor. If you modify the text, it will be compressed again. This happens automatically when moving to another node, or just closing the dialog (this is why there is no "save" button).
To add a new item, press "Add Item". A new item will be inserted below the focused item with the title "New snippet". You can change it's name by clicking the name once with the mouse.
"Add sub item" works like above, but creates a new tree-level under the focused item. Using then "Add Item" you can enter code snippets under the new category.
The tree structure fully implements drag and drop. You can drag files or folders and place them under other folder. To target another folder, release the mouse button on the folder you want. To target the root of code librarian, release over the top most item in the tree.
Note that because you are actually viewing a directory structure, all rules that apply to windows filenames should be followed: Don't use the characters < > / \ : * ? and don't use duplicate names.
Extensions are not shown in the tree view, but icons that represent the file type are used. Also from the file extension, the corresponding syntax parser will be used in the editor. To change the extension, rename the file adding the extension you want, for example head.html or string.pl. If you don't put a dot at the end, the extension will not change.
Code snippets do not have to be actual programs that run, but giving an extension helps add the correct icon and also enables the correct syntax parser to be used in code librarian's editor.
Code librarians snippets are saved in "Code Librarian.zip" in OptiPerl's Application Data folder.
Opening Zip files in general
You can also open any zip file from Tools / Open zip file. The rules that apply to code librarian will also apply here, and you can actually open many zip files plus code librarian in separate windows to drag and drop files.
How to import to Code librarian
Nothing to it! Just collect your favorite files with examples of code, put them in a folder, and use your favorite Zip program (like for example WinZip (r) )to add them to Code Librarian.zip
You can import the old OPL format of OptiPerl from the File menu of code librarian.
When opening zip files, remember that editing in the text box will actually replace the old file, by packing over it.