Example Code

Escape and Unescape Characters to Reserve Text in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Description

1. Overview

This example lets the user escape and unescape a text of selected characters in order to reserve them in a string and automatically check the given list for duplicates.

 

2. Description

These VIs give you the ease to remove a given set of characters from the string, tag the removed characters, and output the escaped string. This is very useful for file formats were certain characters indicate, say, the end of a section. Also, you have the option of attaching a header containing unescaping instructions to the output string.
Escape Text.vi takes a string of text, then scans it for the characters listed in "Escape Characters" and replaces them with the "Escape Indicator" coupled with an unused character. This subvi would be used when you wanted to reserve special indicator characters, so this vi would allow you to reserve them. If you select "Implant Header" as TRUE, then the header detailing how to unescape the string is included in the "Escaped String" output.
Unescape Text.vi reverses the escaping process and restores the original text. You may input the characters that were escaped, as well as the escape indicator, or you may plug in the header that was outputted from Escape Text.vi. If neither terminals are wired, then the program assumes that the header is implanted and attempts to unescape using that.

 

3. Requirements

  • NI LabVIEW Base Development System 2012 (or compatible).

 

4. Steps to Implement or Execute Code

  1. Download the compressed file and open "Escape Text LabVIEW 2012 NIVerified.vi"
    1. Write the string to escape in Unescaped String.
    2. Pass an array of characters to escape in Escape Characters.
    3. If Implant Header is true, then the header detailing how to unescape the string is included in the Escaped String output.
    4. Run the VI.
    5. Copy the escaped output text.
  2. Open the VI "Unescape Text LabVIEW 2012 NIVerified.vi"
    1. Write the string to unescape in Unescaped String.
    2. Pass an array of characters to escape in Escape Characters.
    3. If Implant Header is true, then the header detailing how to unescape the string is included in the Escaped String output.
    4. Run the VI.

 

5. Additional Information or References

Unescape Text LabVIEW 2012 NIVerified.png

 

Escape Text LabVIEW 2012 NIVerified.png

 

 

 

**The code for this example has been edited to meet the new Community Example Style Guidelines.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.