Skip to content

Applying a Template to Existing Members

A default template shapes only the members created after it is chosen. The Apply Code Template command in the Driver Designer gives existing members a template’s body, as if they had been created from it.

  1. In the Driver Designer, select the members to change:

    • one method, property, function, or attribute
    • several of them, using multiple selection
    • an interface reference property in the Hierarchy (for IVI-C, a branch), which selects all the members below it, including those of repeated capabilities
  2. Right-click the selection and choose Apply Code Template….

  3. In the Apply Code Template dialog, choose the Template set and then the template.

  4. Click Apply, or double-click the template.

The change is made as a single operation, so one Undo reverts it.

Template set lists This driver’s set first, followed by the sets in the machine catalog that have a part for the driver’s type. It starts on the driver’s own set, or on the first catalog set when the driver has none. A template applied from a catalog set is not copied into the driver: its text is written into the members’ bodies, and nothing refers to the template afterward.

For the functions and attributes of an IVI.NET driver’s linked IVI-C driver, the templates are IVI-C templates: This driver’s set is the IVI-C part of the driver’s set, and the catalog sets listed are those with an IVI-C part.

The list shows the templates in the chosen set that fit at least one of the selected members. The set’s default template for the kind of member most of the selection is starts out selected. When no template fits, the list says so and suggests adding one on the Code Templates page, and Apply is disabled.

The preview beside the list shows the selected template in context. With a single member selected, the preview is that member, with its real signature and preamble, exactly as Apply will write it. Otherwise, the preview is a stand-in member, as on the Code Templates page.

Below the list, a summary says what the selected template changes: the member it applies to, or how many members it applies to, for example “Applies to 37 methods under Measurement.” It also counts the members of the template’s kind that it does not fit because they have an accessor the template has no file for, and how many members will be switched from Instrument command to Manual with instrument command.

Within the selection, a template changes only the members it fits: members of the kind in its applies-to field, with an accessor file for each accessor the member has, and an eligible implementation style. The others are left as they are. A selection with both methods and properties takes one Apply Code Template for each kind.

Implementation style
Manual, Manual with instrument commandEligible. Class-compliant members, such as IIviDmm.Configure, are Manual.
Instrument commandEligible, and switched to Manual with instrument command when the template is applied. The body becomes manual code, and the instrument command is kept, so the driver’s help still lists it.
AutomaticNot eligible. Nimbus regenerates the body, which would overwrite the template’s code.

Inherent members, Direct I/O members, repeated capability management members, and the IVI-C functions of an IVI-COM driver are never eligible. In an IVI.NET driver, neither are the members of classes that do not implement the driver’s interfaces.

Each member becomes what a new member created from the template would be:

  1. A member that is Instrument command is switched to Manual with instrument command.
  2. The member’s Use standard preamble setting is set from the template’s use-standard-preamble field.
  3. The body is replaced: a freshly written preamble followed by the template’s text when the setting is on, or the template’s text alone when it is off. For a property or attribute, each accessor the template has a file for is replaced.

Everything else in the old body is replaced, so any code written in it is lost. How this plays out depends on the driver type:

  • IVI.NET: the whole body is written again. A method’s simulation code, which follows the preamble, is replaced along with the rest.
  • IVI-C: the simulation code is part of the preamble, so a function keeps its simulation code, and one without any gets the simulation code a new function gets. An attribute keeps its simulation code when its simulation style is Manual.
  • IVI-COM: the template’s text is always the whole body. The member’s forwarding shim is regenerated, so it runs the preamble or not according to the new setting.