Summary: In this lesson, you will learn how to use the String functions.
Note: Your browser may not currently support MathML. See our browser support page for additional details. You can always view the correct math in the PDF version.
Use the String functions located on the Functions>>All
Functions>>String palette to edit and manipulate strings
on the block diagram. String functions include the following:
String Length function
returns a length of 19 for
the following string:
The quick brown fox
Add
Input from the shortcut menu or by resizing the
function. For example, concatenate the previous string with
the following array of strings:
jumped |
over |
the |
lazy |
dog. |
Concatenate Strings function returns the following
string:
The quick brown fox jumped over the lazy dog.
0. For example,
if you use the previous string as the input, the
String Subset function returns the following
substring for an
offset of 4 and a
length of 5:
quick
:
and use the following string as the input:
VOLTS DC: +1.22863E+1;
Match Pattern function returns a before
substring of VOLTS DC, a
match substring of :, an
after substring of
+1.22863E+1;, and an offset past
match of 9.
Use the Build Text Express VI to convert numeric
values into strings. The Build Text Express VI,
located on the Functions>>Output palette,
concatenates an input string. If the input is not a string,
this Express VI converts the input into a string based on the
configuration of the Express VI.
When you place the Build Text Express VI on the
block diagram, the Configure Build
Text dialog box appears. The dialog box shows
the Express VI configured to accept one input,
voltage, and change it to a fractional number
with a precision of 4. The input concatenates on the end of
the string Voltage is. A space has been added to
the end of the Voltage is string.
![]() |
This configuration produces the block diagram shown in Figure 2. A probe has been added to view the value of
the output string. The Build Text Express VI
concatenates the Beginning Text input, in this
case the voltage value, at the end of the
configured text.
![]() |
The Scan From String function converts a string containing
valid numeric characters, such as 0-9,
+, -, e,
E, and period (.), to a numeric
value. This function scans the input
string and converts the string according to
format string. Use this function when you
know the exact format of the input text. This function can
scan input string into various data
types, such as numeric or Boolean, based on the format
string. Resize the function to increase the number of
outputs.
For example, use a format string of
%f, an initial search
location of 8, and VOLTS
DC+1.28E+2 as the input string,
to produce an output of 128, as shown in the
block diagram shown in Figure 3. Change the
precision of the output by changing the precision of the
indicator.
![]() |
In format string, % begins
the format specifier and f indicates a
floating-point numeric with fractional format. Right-click
the function and select Edit Scan String from
the shortcut menu to create or edit a format
string. The Edit Scan
String dialog box shows a configuration for the
format string %4f.
![]() |
Refer to the LabVIEW Help for more information about format specifier syntax.
"A full introductory course on programming with LabVIEW."