Developer Center Resources

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Custom Bookmark Manager for LabVIEW

What are LabVIEW Bookmarks?

One of the exciting new features of LabVIEW 2013 was the introduction of bookmarks.  Bookmarks are a special tagging mechanism that can be added to a VI Block Diagram.  Any text that starts with a hashtag ( # ) will automatically be identified by LabVIEW as a bookmark.  These can be used for marking to-do items or unfinished tasks in different parts of code.  When you add a hashtag to a block diagram comment, LabVIEW detects a bookmark and bolds the bookmark tag to distinguish it from the rest of the text, (for example: "#TODO revise algorithm") .

 

Bookmarks.png

What is the LabVIEW Bookmark Manager?

The Bookmark Manager is a tool for viewing all bookmarks in a project or application instance.  It can be accessed from the View > Bookmark Manager menu item.  When you open the built-in Bookmark Manager, it shows the bookmark and any comments that follow it.  You can also double click any bookmark entry and it will open the VI where it exists and highlight the location on the block diagram.  From the bookmark manager, you can also change the project in which you are viewing bookmarks and change the view.

 

The LabVIEW Bookmark Manager is very simple and useful, but its true power comes from its customizability.  The bookmark API has a fully open interface which can be used to create your own custom bookmark manager.  You can even copy and edit the built in manager to help get you started since the Bookmark Manager is also open and unlocked.

 

Bookmark manager.png

 

Bookmark Manager API

The bookmark manager API is built on the VI Server interface to programmatically access and manipulate the Bookmarks of a VI.  If you are not familiar with VI Server, it may be helpful to first read up on this at "What Is the VI Server?" and "Capabilities of the VI Server".  Along with the existing VI Server interfaces, the bookmark manager API adds 4 more important Events and Methods specific to bookmarks:

 

 

Get VI Bookmarks (VI Method)

The Get VI Bookmarks method will return all the bookmarks associated with a certain VI.  This method uses a VI reference and works for all VIs in memory, including those that have not been saved to disk.

 

Get VI Bookmarks.png

 

Get VI: Bookmarks (Application Method)

The Get VI: Bookmarks method is similar to the Get VI Bookmarks VI Method, except it is a method for the Application class.  This method uses a  VI Path for input and works for any VI on disk, even if they have not been loaded into memory. 

 

Note: Bookmarks are stored as a VI resource on disk but are kept up to date in memory.  This means that a VI does not have to be in LabVIEW's memory in order to read its bookmarks.

 

App Get VI Bookmarks.png

 

Get Object Ref from Bookmark ID (VI Method)

This method will convert a bookmark ID to an object reference.  Note: Bookmarks are referenced by "Bookmark IDs" because Object References are only valid for VI's loaded in memory.

 

get object ref.png

 

Bookmark Info Change (Event)

 

This is an application event that is generated when a user changes the bookmark of a VI.  This can be handled in a LabVIEW Event Structure. 

 

bookmark info change.png

 

Customizing the Built-In Bookmark Manager

 

When creating your own bookmark manager, you may start from scratch, but it may help you save time to use the existing bookmark manager as a starting point.  Complete the following steps in order to copy the existing bookmark manager code:

 

 

  1. Copy the Default folder found in the labview\resource\dialog\BookmarkManager\managers directory. You will use this source as the starting point for developing your bookmark manager.
  2. Paste the folder in the same directory and rename it to something else.
  3. Copy the Default.txt file at the top level of the managers directory and rename it to match the new name of the folder from step 2.
  4. Open the copy of the *.txt file and replace the word Default with the name of your new bookmark manager (this name will appear in the "Select a Bookmark Manager" dialog).
  5. Edit the files in the new folder to accommodate your particular needs.

 

Select a Bookmark Manager

 

 

Once you have multiple Bookmark Manager's located in the labview\resource\dialog\BookmarkManager\managers directory, LabVIEW will allow you to select between them when you choose to launch this from the View menu.  You may choose not to show this selection dialog, but anytime a new bookmark manager is found it will prompt again allowing you to change to the new one. 

 

select.png

 

Caveats and Hints For Development

 

  1. When copying the Default Bookmark manager, make sure to watch out for cross-linking of files between the new folder and existing "Default" folder.  After initially copying the folder, you should make sure to check that all files in the new project point to the files in the new folder.  Once this is fully working once, it is also recommended to rename the project and project libraries in order to prevent future cross-linking.
  2. Copy the default bookmark manager instead of modifying the original.  This will allow you to revert to the built-in bookmark manager in case anything goes wrong. 
  3. When testing your bookmark manager, make sure to completely save and close the VIs and projects before running the bookmark manager from the View menu.  Also, if you need to use breakpoints or highlight execution in your code, make sure to close the running VI and re-open the project before modifying any code.  The reason for this is that LabVIEW puts the Bookmark Manager Dialog VI in a state when run from the Tools menu called a System VI.  On exit, the VI is reverted to an editable state.  However if you stop the Bookmark from running part way through execution, the VI will remain in this state permanently and may cause unexpected behavior.  A System VI will not show any errors in the "Error List" window if they are broken and System VIs do not appear in the Hierarchy window. 
    • If you accidentally get your VI stuck in the "System VI" state, you can use the attached "Is System VI Write" VI to unset your VI as a system VI. 

 

Distributing your Bookmark Manager with VI Package Manager

 

Once you have created your own bookmark manager dialog, it may be helpful to distribute this using VI Package Manager.  This will allow your users to easily install the files in the right directory and mass compile the VIs to the current version during installation.  To do this, all you need to do is add a custom destination in the VI Package Builder for your project as shown below.  More details on using VIPM to build a package can be found in the document VI Package Manager: An Introduction

 

VIPM.png

 

Submit your bookmark manager to the NI Tools Network

 

If you think other users in the world would benefit from your new Bookmark Manager, consider submitting it to the NI Tools Network as either a free download or a paid product.  More information on how to submit can be found at Contribute a LabVIEW Add-On to the Tools Network.

 

Example:  Bookmark Manager with Block Diagram Preview

 

To demonstrate how you can modify and add features to the existing Bookmark Manager, this modified version demonstrates the information discussed in this document.  This new version adds an image control on the right side of the dialog that shows a preview of the block diagram code surrounding the selected Bookmark.  The image panel is resizable and the default window and panel sizes are saved between sessions.  The example can be downloaded and installed from VIPM at vipm://ni_bookmarkmanager_bdpreview

 

Bookmark manager with block diagram preview.png

 

Related Links

[NIWeek 2013] Bookmark API in LabVIEW 2013

LabVIEW Help: Creating a Bookmark Manager

NIWeek 2013 Keynote: Enabling a Community With LabVIEW 2013