VI Analyzer Enthusiasts Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Test - Search and Replace

Search and Replace reports a failure if any of a number of user-specified patterns are matched in the VIs under test, optionally replacing the matched pattern. You can use Search and Replace to:

  • Identify all VI text matching a regular expression.
  • Clean up autogenerated control/indicator labels. For instance, you can fixup incorrectly named error clusters, or remove ".lvclass" from labels, or rename LVClass labels when the class has been renamed, etc.
  • Update string constants.
  • …and more!

Before/after running Search and ReplaceBefore/after running Search and ReplaceConfiguration sampleConfiguration sampleSample outputSample output

 

 

Important Notes

BACK UP YOUR CODE BEFORE USING THIS TEST TO MODIFY VIS.
AVOID MODIFYING VIS WHICH ARE ALREADY LOADED IN MEMORY.

 

This tool has rarely, but demonstrably, caused corruption when modifying VIMs whose callers are presently in memory. It is not yet known if this issue is limited to VIMs. Running VI Analyzer with no other VIs open, or excluding VIMs from modification, may avoid this issue. To work around this  issue, disable VI modification and make requested changes by hand.

 

This issue is tracked by Bug 1136631.

 

Instructions

Install in the usual way. Saved in LabVIEW 2015.

 

Search and Replace can apply an array of match specifications, each of which contains the following elements. (Due to space constraints, configuration checkboxes for each element lack labels; see legend at the bottom of the configuration page.)

  • pattern: the pattern to match. This is either a regular expression or a literal string depending on the value of the "literal?" config option.
  • replace: the string to replace the matched pattern with. When "literal?"=FALSE, you can make use of match groups ($1, $2, ...) to substitute in capture groups from "pattern".
  • control labels: pattern applies to control labels.
  • indicator labels: pattern applies to indicator labels.
  • control/indicator description: pattern applies to control and indicator descriptions.
  • VI description: pattern applies to VI descriptions.
  • BD Labels: pattern applies to free text labels and node labels on the block diagram.
  • string constants: pattern applies to string constants on the block diagram.
  • ctl databinding path: pattern applies to controls bound to shared variable paths.

Test-wide configuration options include:

  • modify?: If TRUE, VIs are modified in-place and saved according to the match specifications. See "IMPORTANT NOTES" for important caveats to enabling this. Regardless of the value of "modify?", each matched string is reported as a VI Analyzer error.
  • ignore case?: Matches are case-insensitive.
  • literal?: Matches are plain strings.
  • replace all?: Each match+replace is applied repeatedly until it no longer matches.
  • multiline?: If "literal?"=FALSE, patterns apply across line boundaries.

Limitations

Does not yet support the following:

  • Subdiagram labels
  • Free text labels on Front Panel
  • I/O refnums
  • Control/Indicator tip strips
  • Per-match-specification control of "ignore case?", "literal?", "replace all?", and "multiline?"

Because of the "IMPORTANT NOTES" listed above, using this test to modify VIs in an open project is strongly discouraged.

 

Version History

18 September 2020: initial release.

19 September 2020: backport to LabVIEW 2015. Add support for control databinding paths.

Comments
rtollert
Member
Member
on

(This post intentionally left blank for future post-2018 LLB variant)

Contributors