Loading and Saving VIs


Obviously, you will be loading and saving VIs quite a bit during your development. LabVIEW has many features that can accommodate your file storage needs, and this section discusses how you can make them work for you.

You can load a VI by selecting Open from the File menu, and then choosing the VI from the dialog box that appears. As the VI loads, you may see a status window that lists the subVIs that are currently being loaded and allows you to cancel the loading process. You can load a specific VI by double-clicking on the VI's icon (either in the LabVIEW Project Explorer, or directly from the operating system's file manager) or by dragging the icon on top of the LabVIEW icon. If LabVIEW is not already running, it will first launch and then open the VI.

Save VIs by selecting Save (or a similar option) from the File menu, or use the keyboard shortcut <ctrl-S> (Windows), <command-S> (Mac OS X), or <meta-S> (Linux). LabVIEW then pops up a file dialog box so you can choose where you want to save

Keep in mind that LabVIEW references VIs by name. You cannot have two VIs with the same name in memory at one time (unless they are members of different project libraries, which we will discuss in Appendix D, "LabVIEW Object-Oriented Programming"). When searching for a VI of a given name, LabVIEW will load the first VI it finds, which may not be the one you intended.

Note that an asterisk (*) marks the titles of VIs that you've modified but not yet saved (see Figure 5.1). We're sure you already know to save your work constantly, but we'd like to stress the importance of saving frequently and backing up everything you do on a computeryou never know when lightning will strike (literally)!

Figure 5.1. A VI window title with an asterisk (*) indicating that the VI has unsaved changes


Never save your VIs in the vi.lib directory. This directory is updated by National Instruments during new version releases of LabVIEW, and if you put anything in there, you may lose your work.


Save Options

You can save VIs with one of four save options in the File menu.

Select the Save option to save a new VI and then specify a name for the VI and its destination in the disk hierarchy; or use this option to save changes to an existing VI in a previously specified location. Save All works just like Save except that it applies to all VIs in memory that have unsaved changes.

Save As . . . brings up the dialog box, shown in Figure 5.2, in which you can choose to Copy or Rename the VI.

  • Copy, which creates a copy on disk, has three sub-options:

    • Substitute copy for original This is a "traditional" Save As . . . operationit renames the VI in memory and saves a copy of the VI to disk under the new name. All VIs currently in memory that call the old VI now point to the new VI.

    • Create unopened disk copy This simply creates a copy on disk. It does not open the copy into memory.

    • Open additional copy This creates a copy on disk, and then opens the copy. Unlike Substitute copy for original, all VIs currently in memory that call the old VI still point to the old VI.

  • Rename renames the VI in memory and then moves (renames) the file on disk. Note that the original file is deleted. All VIs currently in memory that call the VI now point to the VI in its new location.

    Figure 5.2. Save As dialog

Save for Previous Version . . . brings up a dialog box, shown in Figure 5.3, in which you can choose to save the VI and all of its components to a previous version of LabVIEW.

Figure 5.3. Save for Previous Version dialog


Revert

You can use the Revert . . . option in the File menu to return to the last saved version of the VI you are working on. A dialog box will appear to confirm whether you want to discard any changes in the VI.

LLBs

LLBs are special LabVIEW files that have the same load, save, and open capabilities as directories and folders within the LabVIEW environment. You can group several VIs together and save them as an LLB, much like you would store files inside one zip file. LLBs offer few advantages and many disadvantages; for example, they can contain only LabVIEW file types, not data or other files. In addition, your operating system sees LLB files as single files, and you can access their contents only from LabVIEW.

Note that many of the VIs shipped with LabVIEW are kept inside LLB files.

In the last few years, the trend has been to no longer use LLBs. LLBs were created in the early days of Windows in part to handle the old limitations of eight-character filenames, and have remained to this day for compatibility purposes. Storing your VIs as individual files, organized in directories, will usually make more sense.


LLB files were at one time referred to as "LabVIEW Libraries," hence the name and file extension ".llb." However, LabVIEW now has the project library, which is a logical collection of VIs used in LabVIEW projects. In comparison, LLB files are simply aggregates of LabVIEW files on disk. In this book, when we use the term "library," we are referring to project libraries and will exclusively use the term "LLB" for referring to LLB files.


For the activities in this book, we've asked you to save your work in a MYWORK directory, so that you can access individual files more easily. We also encourage you to not use LLB files for storing your day-to-day work. The LabVIEW Project Explorer, which you learned about in Chapter 3, "The LabVIEW Environment," provides you with a great way to organize your VIs and other project files.

How to Use LLBs

Create an LLB from the Save or Save As . . . dialog box by clicking on the New LLB button under Windows or the New . . . button on Mac OS X. If you're on a Mac configured to use native dialog boxes, you will have to click on the Use LLBs button from the Save dialog box, and then select New . . . from the dialog box that appears.

Enter the name of the new LLB in the dialog box that appears, shown in Figure 5.4, and append an .llb extension. Then click on the LLB button, and the LLB file is created. If you do not include the .llb extension, LabVIEW adds it.

Figure 5.4. New LLB dialog


Usually you will create an LLB when you are saving a VI, so after the LLB file is created, a dialog box appears to let you name your VI and save it in your new LLB.

Once you've created an LLB, you can save VIs in it and access them through LabVIEW much like a directory or folder, but you cannot see the individual VIs from your operating system (unless you are on a Windows system and have checked the Enable Windows Explorer for LLB files option in the Environment section of the Tools>>Options . . . dialog). Remember that on Macs configured to use native dialogs, you'll have to select Use LLBs from the Save dialog box in order to access them.

On Windows, LabVIEW installs a File Explorer extension that allows you to navigate into LLB files as if they were folders on disk. This feature is enabled by default, and is controlled by the Enable Windows Explorer for LLB Files setting in the Environment category of the Tools>>Options . . . dialog. If you change this setting, you will need to reboot your computer before you will see the effect of the change.


The LLB Manager

Because you can't do it through your operating system, you must use the LLB Manager to edit the contents of an LLB. You can use the LLB Manager (from the Tools menu) to simplify copying, renaming, and deleting files within LLBs as well as within your file system itself. You also can use this tool to create new LLBs and directories and convert LLBs to and from directories. Creating new LLBs and directories and converting LLBs to and from directories is important if you need to manage your VIs with source code control tools. (Yes, you can use the Windows Explorer for LLB Files feature, but it does not provide all the features of the LLB Manager.)

You can open more than one instance of the LLB Manager and drag and drop files between the instances to move or copy the files from one location to the other. Holding down the <Ctrl> key while you drop a file will cause the file to be copied rather than moved.


You can open VIs from the LLB Manager by double-clicking them.


You can also use the LLB Manager to modify the Top Level attribute of VIs within an LLB. If you mark a VI as Top Level, it will load automatically when you open the LLB file, as shown in Figure 5.5. You can have more than one top-level VI in an LLB file. Top-level VI names will also appear in a separate section at the top of the Load dialog, so it's easier for you to determine which VIs are main VIs and which are subVIs.

Figure 5.5. LLB Manager


Save and Load Dialogs

LabVIEW supports the File dialog box format that your system uses. When you open or save a VI, your system File dialog box appears. If you click on an LLB file (a special LabVIEW file storage structure that can contain VIs (as well as some other LabVIEW file types) within it, similar to how a ZIP file can contain other files), LabVIEW replaces the system dialog box with its own File dialog box so that you can select files within the LLB.

Because the interface for selecting and saving into an LLB is somewhat awkward with the system dialog box, you may prefer to set the LabVIEW options to use the standard LabVIEW dialog box if you commonly use LLB files. Select Options . . . from the Tools menu, then go to the Environment menu and uncheck the Use native file dialogs box.

The standard LabVIEW dialog box also saves shortcuts to recently selected folders, which are available from a pull-down menuthis can save you time. However, using the LabVIEW Project Explorer to manage your project VIs makes this feature less important.


The Save dialog box in Mac OS X disables files from LLBs. You will need to click the Use LLBs button in order to save into a LabVIEW LLB file, or use the standard LabVIEW dialog box instead of the native one.

Filter Rings

At the bottom of your Save or Load dialog box, you will see a filter ring that allows you to view All Files, view only All LabVIEW Files, VIs & Controls, VIs, Controls, Templates, Projects, Run Time Menu Files, Project Libraries, or XNodes files, or just see those with a Custom Pattern that you specify.

The Custom Pattern option is not available on some native-style dialog boxes.


If you choose Custom Pattern, another box appears in which you can specify a pattern. Only files matching that pattern will show up in the dialog box. Notice that an asterisk automatically appears inside the box; this is the "wild-card character" and is considered a match with any character or characters.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net