How Does the Backslash '\' Codes String Display Mode Work?

Updated May 23, 2019

Reported In

Software

  • LabVIEW Full

Issue Details

When I right click on a string control or indicator on my LabVIEW front panel, I see the option to change to a '\' Codes Display. What exactly does this do?

Solution

The '\' Codes Display, often called "backslash codes display", allows you to see a string as it is actually represented in memory as opposed to how it is displayed on your front panel. 

For example, the backslash code for a space character is \s. If you type Hello World! into a string control with a normal display and then change the string control into a backslash codes display, you will see Hello\sWorld!. The space character was replaced by its backslash code equivalent. If a character in a string does not have a common escape character (i.e. \s for space and \t for tab), it will be represented by a backslash followed by the ASCII value of that character in hex. For example, if you have an ESC character in your string, it would be represented as \1B which is the ASCII value for ESC. 
Furthermore, if you type Hello\sWorld! using the default Normal Display then switch to '\' Codes Display, you will notice that the text changes to Hello\\sWorld! which in this case would introduce unintended additional white space into the command. Using '\' Codes Display when writing commands will help prevent syntactical errors when converting ASCII string codes to backslash codes.

Additional Information

The backslash codes display is especially useful when you are using serial communication and the termination characters are important. For example, a common command to be sent to a serial instrument is *IDN?\r\n where the \r\n represent a carriage return and a line feed, respectively. In a string control in normal display mode, this string looks like *IDN? because the \r and the \nare not displayable characters. To make sure you are terminating your commands correctly, go to the backslash codes display and make sure the appropriate termination characters are visible.

WAS THIS ARTICLE HELPFUL?

Not Helpful