Summary: In this lesson, you will learn how to use the String functions.
Functions>>All
Functions>>String palette to edit and manipulate strings
on the block diagram. String functions include the following:
| String Length | - |
Returns in length the number of
characters (bytes) string, including
space characters. For example, the String Length function
returns a length of 19 for
the following string:
The quick brown fox | |||||
| Concatenate Strings | - |
Concatenates input strings and 1D arrays of strings into a
single output string. For array inputs, this function
concatenates each element of the array. Add inputs to the
function by right-clicking an input and selecting Add
Input from the shortcut menu or by resizing the
function. For example, concatenate the previous string with
the following array of strings:
Concatenate Strings function returns the following
string:
The quick brown fox jumped over the lazy dog. | |||||
| String Subset | - |
Returns the substring of the input
string beginning at
offset and containing
length number of characters. The
offset of the first character in
string is 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 | |||||
| Match Pattern | - |
Searches for regular expression in
string beginning at
offset, and if it finds a match, splits
string into three substrings. If no
match is found, match substring is
empty and offset past match is
:
and use the following string as the input:
VOLTS DC: +1.22863E+1;The 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.
|
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.
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.
![]() Figure 1 |
Build Text Express VI
concatenates the Beginning Text input, in this
case the voltage value, at the end of the
configured text.
![]() Figure 2 |
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.
%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.
![]() Figure 3 |
% 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.
![]() Figure 4 |
Comments, questions, feedback, criticisms?
"A full introductory course on programming with LabVIEW."