Using Code Snippets from the Code Library
The Code Librarian organizes code snippets and samples using categories, keywords, and item type icons. You can use the Code Librarian Explorer to locate code items, or you can perform searches on the keywords associated with the code items.
When you select a code item in the Code Librarian Explorer, a description of the item is displayed in the field below the explorer.
Searching for Code in the Code Librarian
You can specify search criteria for finding source code in the Code Librarian database. The search engine limits the search based on the selection you make in the Search Options area. The default is to search by title, code, descriptions, and keywords.
To search the Code Librarian for a code item
Open the Code Librarian. For details, see Opening the Code Librarian.
From the Code Librarian Menu, select Find.
In the Find in Code Library dialog box, select the desired search types in the Options field.
If you do not want to search by Titles, Code, Descriptions, or Keywords, then clear the check box for the respective option.
In the Find What field, type what you want to find.
In the Look in field, select the library you want to look in, and then click Find.
After searching, the Search Results window displays the name of the library item, its category, and its type.
To open one of the library items, double-click the item you want to open.
To copy the code item to a new location, you can use the drag-and-drop feature. For example, to copy the item to a different category within the Code Librarian, drag the library item to the new category folder to create a copy in the new location. To add the code item to your application, drag the code item onto your code editor surface.
Inserting Code into your Project from the Code Librarian
When you have found the code snippet you wish to use, you can easily insert it in your code module by dragging it onto your code module or by copying the code to the Clipboard and pasting it into the code module.
To drag code from the Code Librarian into an existing code module
- In the Code Librarian Explorer select the category or code item you want to copy.
- Double-click the code item to view the code.
- Using the mouse, drag the selected code from the Code window to the desired location in your code module.
When you release the mouse, the selected code is inserted in the location.
To insert code from the Code Librarian into an existing code module
- In your code module, place the cursor in the location where you want to insert the code.
- In the Code Librarian, select the code snippet you want to copy.
- From the Edit menu, select Copy to add the code item to the Clipboard. Place your cursor in the code item where you want to paste the code.
- From the Edit menu, select Paste.
The code from the Code Librarian is inserted in your code module.
See Also
Customizing Code in the Code Librarian | Making the Code Librarian Available to Multi-users | Distributing Code Samples with the Code Librarian Viewer