New Project and File Templates
You can create projects and files to use as templates for new projects and files. Using project and file templates can help reduce the time and effort required to configure a new project or file. The template includes the basic settings for the new project or file and any preliminary text to include by default, such as standard comments or headings. You can create a template for any type of file including .c, .h, and .uir files.
Creating Templates
Complete the following steps to create a project or file template:
- Create a project or file.
- Set any standard options and/or add standard text. Include template variables.
- Save your file in the appropriate location. If you have multiple templates, create multiple folders in the appropriate location and save one template per folder.
You can provide a description of any template you create. To do so, include a templateinfo.ini file in the template directory. The template file has the following format:
[Description]
Description = "Place your description here"
LabWindows/CVI displays the description in this file when you select the corresponding template type in the New Project from Template dialog box or the New File from Template dialog box. When you create a new project or file from a template, LabWindows/CVI copies the file(s) from the specified template directory, except for the templateinfo.ini file, to the directory of the new project or file.
Creating Projects and Files from Templates
To create a project or file from a template, select File»New»Project from Template or File»New»File from Template. LabWindows/CVI includes predefined project and file templates, which are listed in the New Project from Template and New File from Template dialog boxes. Templates you create are added to the lists of predefined templates in these dialog boxes.
![]() |
Note If you create a project template folder that contains a workspace file, LabWindows/CVI loads that workspace when you select the corresponding item in the New Project from Template dialog box. This is useful if you want to load multiple projects in a workspace by default. |
![]() |
Note If the specified file template includes two files, one of which is a .h file, LabWindows/CVI copies the .h file only if you enable the Create corresponding .h file option in the New File from Template dialog box. |
Template Variables
When LabWindows/CVI copies the template file, it substitutes the appropriate value for any template variables that you included in the template file. For example, if you create a project template named [[PROJECTNAME]].prj and specify TestProject for the Project name option in the New Project from Template dialog box, LabWindows/CVI creates a copy of the project template named TestProject.prj.
LabWindows/CVI provides the following template variables:
Variable | Value | ||
---|---|---|---|
[[DATE]] | Current date. | ||
[[TIME]] | Current time. | ||
[[FOLDER]] | Full pathname of the file's parent folder. LabWindows/CVI obtains this value from the Project folder/File folder control in the New Project from Template/New File from Template dialog box. | ||
[[FILENAME]] | Filename plus extension. | ||
[[FILEBASENAME]] | Filename without extension.
|
||
[[FILEBASENAMEASIDENTIFIER]] | Filename, converted to a valid C identifier. | ||
[[FILEEXTENSION]] | File extension. LabWindows/CVI obtains this value from the template file extension on disk. | ||
[[PROJECTNAME]] | Project name without extension. LabWindows/CVI obtains this value by joining the text you enter in the Project name control in the New Project from Template dialog box plus any other text in the template filename, excluding [[PROJECTNAME]]. | ||
[[PROJECTNAMEASIDENTIFIER]] | Project name, converted to a valid C identifier. | ||
[[USERNAME]] | Account name of the current user. LabWindows/CVI obtains this value from the current login name on the Windows system. | ||
[[FULLUSERNAME]] | Full name of the current user. LabWindows/CVI obtains this value from the system registry. | ||
[[COMPANYNAME]] | Company name. LabWindows/CVI obtains this value from the system registry. |
Template Locations
LabWindows/CVI can access project and file templates from different locations on your computer.
- LabWindows/CVI installs its predefined templates in the <Program Files>\National Instruments\CVIversion\ directory. Project and file templates are installed within \Project Templates and \File Templates folders in this directory.
- Install templates that you create in the LabWindows/CVI public documents directory (Users\Public\Documents\National Instruments\CVI. Create \Project Templates and \File Templates folders within these directories to hold your user-defined templates.