Custom LabVIEW configuration file

From LabVIEW Wiki
Jump to: navigation, search

In the following, project has a pre-LabVIEW 8 meaning e.g. a collection of related VIs

Customize LabVIEW.ini to your project

The LabVIEW Preference file is stored by default in the LabVIEW installation directory. Often LabVIEW developers use only this default labview.ini for all their projects, ignoring the benefits of having one preference file for each project. Maybe this is due to the fact that it is not straightforward to open LabVIEW with a specific ini file.

Using LabVIEW with a custom ini file

Command Line

From the command line you have to specify the ini file with the -pref switch:

"c:\Program Files\National Instruments\LabVIEW 8.2\LabVIEW.exe" -pref "c:\MyProject\labview.ini"

This is not a very convenient method to start LabVIEW.


Another method is to create a shortcut with the above command line. For each project edit a different shortcut specifying the ini file. This is far more convenient than the command line

Custom file extensions

Create a custom file extensions for LabVIEW ini files. Change the file extension of the preference file to something like *.lv82ini. Then in Windows create this file extension specifying the following action:

"c:\Program Files\National Instruments\LabVIEW 8.2\LabVIEW.exe" -pref "%L"

With this setup you can start LabVIEW with a custom ini file just by double clicking on the lv82ini file of the project. If you work with more than one version of LabVIEW, create one file extension for each version like *.lv80ini and *.lv71ini with actions using the corresponding LabVIEW executable. That allows to conveniently start with the LabVIEW version and the preference file of the project.

Already invoking LabVIEW from a shortcut or an action on a file extension, we can also make the command to run a VI. For example, setting the file extension action to run

"c:\Program Files\National Instruments\LabVIEW 8.2\LabVIEW.exe" "c:\tools\" -pref "%L"

will open the VI when launching LabVIEW from a preference file. That VI, set to run when opened, can execute any suitable initialization task and load/run VIs specific to the project looking into the project directory (see below).

Benefits of a custom ini file

Default Path

The first thing to do using an ini file customized for your project is to set the default path setting to the project root path. You will soon realize that the file dialogs will show your project path as the startup directory rather than the LabVIEW directory. The file constant "Default Directory" will return the project directory so it is easy to build paths relative to the project directory without harcoding it. If you move the project folder, only change the default directory setting and relative paths will change accordingly. Moreover, in a built application, this default directory will default to the application directory so you can keep the same directory structure and relative paths in the built application without changing the code or checking if the application runs in Development or Run-Time LabVIEW.

Browse history

The browse history (recently opened files and used directories) is stored in the ini file. Custom ini files allow to keep a different history for each project so in the list of recently opened files you see files opened whitin this project rather than files opened in an unrelated project.

Source Code Control (SCC)

Since LabVIEW 8 SCC settings are stored in the preference file. Customized ini files then allow to have different SCC settings and providers for different projects. In LabVIEW 7.1 and before, SCC settings are stored in files kept in the default directory so if you take care of setting the default directory to the project directory, you can also have different SCC setting for each project. LabVIEW 8.5 (and up) gives the ability to use .lvproj dependent SCC settings.

Other Project dependent Settings

Other settings might be project dependent like the palettes, search paths, decimal separator etc. All these can be set independantly for each project.

The Project custom ini file is typically stored in the project directory and can be copied from the default labview.ini or from some convenient template. It is also logical to keep this file under SCC to make sure that LabVIEW is correctly configured for the project usage. For example, using an incorrect decimal separator setting can easily break an application.

See Also

LabVIEW configuration file