Backslash ('\') Codes Display

Right-click a string constant, control, or indicator and select '\' Codes Display from the shortcut menu to instruct LabVIEW to interpret characters that immediately follow a backslash (\) as a code for non-displayable characters. The backslash mode is useful for debugging VIs and for sending non-displayable characters to instruments, serial ports, and other devices. The following list shows how LabVIEW interprets these codes.

Code LabVIEW Interpretation
\00 – \FF Hex value of an 8-bit character; must be uppercase
\b Backspace (ASCII BS, equivalent to \08)
\f Form feed (ASCII FF, equivalent to \0C)
\n Linefeed (ASCII LF, equivalent to \0A)—The Format Into File function automatically converts this code into the platform-dependent end-of-line character.
\r Carriage return (ASCII CR, equivalent to \0D)
\t Tab (ASCII HT, equivalent to \09)
\s Space (equivalent to \20)
\\ Backslash (ASCII \, equivalent to \5C)

Use uppercase letters for hexadecimal characters and lowercase letters for special characters, such as form feed and backspace.

LabVIEW interprets the sequence \BFare as hex BF followed by the word are. It interprets \bFare and \bfare as a backspace followed by the words Fare and fare. In the sequence \Bfare, \B is not the backspace code, and \Bf is not a valid hex code. In a case like this, when a backslash is followed by only part of a valid hex character, LabVIEW assumes a 0 follows the backslash, so LabVIEW interprets \B as hex 0B. Any time a backslash is not followed by a valid hex character, LabVIEW ignores the backslash character.

You can enter some non-displayable characters listed in the previous table from the keyboard, such as a carriage return, into a string control regardless of whether you select '\' Codes Display. However, if you enable the backslash mode when the display window contains text, LabVIEW redraws the display to show the backslash representation of any non-displayable characters and the \ character itself.

Complete the following steps to practice using the '\' Codes Display shortcut menu item.

  1. Add a string control to the front panel window. The default mode is Normal Display.

     Add  Find
  2. Resize the string control to display multiple lines of text and enter the following string:

    LEFT

    \RIGHT\3F
  3. Right-click the string control and select '\' Codes Display from the shortcut menu. The string appears as follows because the carriage return after LEFT and the backslash characters around RIGHT are shown in backslash form.

    LEFT\n\\RIGHT\\3F
  4. Repeat step 1 to add a new string control to the front panel window.
  5. Right-click the new string control and select '\' Codes Display from the shortcut menu.
  6. Resize the string control to display multiple lines of text and enter the following string:

    LEFT

    \RIGHT\3F
  7. Right-click the string control and select Normal Display from the shortcut menu. The string appears as follows because LabVIEW originally interpreted \r as a carriage return and now prints one. \3F is the ASCII representation of the question mark (?).

    LEFT

    RIGHT?
  8. Right-click the string control again and select '\' Codes Display from the shortcut menu. The string appears as follows:

    LEFT\nRIGHT?

Indicators behave the same way. Notice that the data in the string does not change from one mode to the other. Only the displayed representation of certain characters changes.