LabVIEW Termination Characters

Overview

LabVIEW provides three termination character string constants: Carriage Return, Line Feed, and End of Line. When adding one of the termination character constants to a string, they appear to have the same result – a line break. However, at the operating system level, each character is interpreted differently. This document discusses the differences between these termination characters and how they appear in LabVIEW.

Contents

Termination Character Functions

Each termination character representation depends on the string format being used.

In the section below, each character is presented in backslash codes display, ASCII, Hex, and LabVIEW visualization. Each character explanation also contains a LabVIEW snippet where the termination character constant is used to create a string output displayed in Normal view and in Backslash code View.

  • Normal Display can be thought of as the human-readable result and is the default for LabVIEW string representations. It displays all characters as typed with the exception of non-displayable characters.
  • Backslash (‘\’) Codes Display translates non-displayable characters (like space, tab, termination characters) into their code form. This setting can be turned on by right-clicking on the string control/indicator on the front panel and selecting ‘\’ Code Display from the Configuring Strings shortcut menu.


Notice that for each snippet, the Normal view shows the same outcome for the termination characters – a line break. However, if you look at the ‘\’ Code Display (i.e. machine-readable output), you will see that the output depends on the termination character used.

Note: the termination character you should use depends on your use case and communication protocol your device uses. Consult the manual for your instrument to determine which termination character and format you should use.

Carriage Return Character  

The Carriage Return (CR) character moves the cursor to the beginning of the line without advancing to the next line. This character is used as the new line character in Commodore and Early Macintosh operating systems (Mac OS 9 and earlier). 

Codes Display ASCII Decimal Hex LabVIEW Glyph
\r 13 0x0D


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
 

Line Feed Character  

The Line Feed (LF) character moves the cursor down to the next line without returning to the beginning of the line. This character is used as the new line character in Unix based systems (Linux, macOS X, Android, etc). 

Codes Display ASCII Decimal Hex LabVIEW Glyph
\n 10 0x0A


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
 

End of Line Character  

The End of Line (EOL) character is actually two ASCII characters – the combination of the CR and LF characters. It moves the cursor both down to the next line and to the beginning of that line; this is the equivalent of the enter key in most typing software. The EOL character is used as the new line character in most other non-Unix operating systems, including Microsoft Windows and Symbian OS.

Codes Display ASCII Decimal Hex LabVIEW Glyph
\r\n 13 10 0x0D0A



Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.

Device Communication

Termination character choice is important when communicating with instruments as each device follows its own communication protocol. Independent of whether you are using the LabVIEW built-in character constants or sending text-based commands, it is important to consider your device’s communication protocol and termination character needs.

Use Cases