I was prompted to write this post after hearing a LabVIEW presentation at a recent user group where somebody made a throwaway comment “I don’t see the benefit of using bookmarks, I can find the code I’m looking for simply by filename”.
I was tempted to jump in an add my thoughts right away, but two things stopped me:
- I’m British; It’s simply “Not Cricket” to interrupt a presentation in such a manner.
- A blog post on this subject would fit very nicely into a series I’d like to write on “Building your own CI System with tools other people created”…..I needed a kick in the ass so to speak.
Bookmarks have been around for several versions now, I want to say 2014 / 2015 but I’m sure somebody can chime in with the exact version (DNatt ?). That being said, my use of them was sporadic to begin with until I started to see some uses when linked to two tools I’ve been working on, but more on that later.
Generally speaking, a bookmark is something that lets you find useful information more quickly; i.e a bookmark in an actual book (remember those?) or a bookmark in your favourite internet browser taking you to your favourite YouTube Channel quickly.
So what is a bookmark in LabVIEW?
Put simply, a bookmark is a free text label with a hashtag. When used in conjunction with the LabVIEW bookmark manager this makes searching for specific comments much easier.
So let’s take a look at this. In the video below we’re going to create our first bookmark in a VI and then try to find it again using the bookmark manager.
First we create a Free Label and then add a # (hash) followed by the text we want to use as our bookmark. The bookmark ends at the first instance of whitespace at which point any remaining text becomes a comment associated with the bookmark.
So for example: #thisIsTheBookMarkPortion This is the comment portion.
You can use camel casing or underscores to highlight word separation in the bookmark text.
Note that the text between the # and the first whitespace is automatically displayed in bold.
The bookmark manager (View Menu > Bookmark Manager) can be used to display all bookmarks in the currently loaded project/hierarchy and provides options for sorting by VI or by bookmark.
Pro Tip – Free labels including bookmarks can display hyperlinks. Just add the full URL followed by space. This is super useful for linking to manufacturer datasheets from your block diagram.
If you stop reading now and start using bookmarks in your code the world will be a much happier place.
As your usage of bookmarks increases, I’m fairly confident you will find yourself using certain bookmarks more frequently such as leaving yourself a note to remind you to come back and fix something or complete some feature you were working on.
If this is the case then you might want a fast way of dropping a bookmark onto the block diagram and for this Shell VIs can be useful (I always thought they were called Merge VIs but I’m getting forgetful in my old age, either that or NI changed the naming to avoid confusion as more and more developers use source code control)
A Shell VI is a VI that when dropped onto another VIs block diagram, places its own block diagram contents rather than placing itself. They’re really useful for demo code but also for dropping pre-written bookmarks.
Please leave a comment if you’re interested in seeing how to create shell VIs and add them to the palette in more detail in a future post. Alternatively, just Google “Shell VIs”.
In the following video, I’ve created a #KnownIssue bookmark inside a Shell VI to remind me that there’s code here that doesn’t behave as expected or as desired. At some point in preparing for a future release, I may search for all instances of #KnownIssue to be resolved before release.
Using the #KnownIssue bookmark is as simple as dropping the Shell VI from the palette at which point its content (the bookmark) is actually dropped.
#ToDo is another useful bookmark that can act as a useful reminder that there’s code still to be completed or modified.
But “the palettes are no good for finding things” I hear you cry. Fear not for some wise person at NI created a feature called “Quick Drop” which allows rapid placement of VIs on the block diagram.
Pro Tip – If you’re not using Quick Drop, you’re missing out. It took an old dog like me a few months to undo all of that LabVIEW 3.1 muscle memory but now I’m sold.
Using a combination of Shell VIs (in the palette) and Quick Drop provides a very rapid way of dropping those pre-written bookmarks. Simply invoke Quick Drop with CTRL + SPACE (CTRL + SHIFT + SPACE on Mac) and type the name of the Shell VI followed by the enter key. Quick Drop even filters the results as you’re typing so no need to memorise the entire name.
The code below can be used to add a short key combination to Quick Drop for an even quicker way of dropping them.
You only need to run this code once (or after adding new bookmarks) as it modifies your LabVIEW config data file (INI file).
Finally, we are in a position where hitting CTRL+SPACE and typing KI followed by ENTER sees a #KnownIssue bookmark being placed on the block diagram. It takes 2 seconds.
The cool thing is that you can create your own bookmarks using the above method. What are you waiting for?
In my next post, we’ll be looking at using bookmarks in conjunction with VI Analyzer to make it even more useful.
See you next time 🙂
PS. If you want to get your hands on the Bookmarks shown in the videos, download this ZIP containing a VI Package.