Connexions

You are here: Home » Content » String Functions
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
Affiliated with (?)
This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • This module is included in aLens by: National InstrumentsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "A full introductory course on programming with LabVIEW."

    Click the "National Instruments" link to see all content affiliated with them.

    National Instruments
Also in these lenses
  • This module is included inLens: Connexions Books Available for Print on Demand
    By: ConnexionsAs a part of collection:"LabVIEW Graphical Programming Course"

    Comments:

    "This book is available through the Connexions beta version of print-on-demand from online materials."

    Click the "Printable Books" link to see all content selected in this lens.

    Printable Books
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

String Functions

Module by: National Instruments

Summary: In this lesson, you will learn how to use the String functions.

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 -  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:
jumped over the lazy dog.
The 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 -1-1. For example, use a regular expression of : 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.

Converting Numeric Values to Strings with the Build Text Express VI

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.
ConfigBuildText.png
Figure 1
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.
BuildTextEx.png
Figure 2

Converting Strings to Numeric Values with the Scan From String Function

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.
Example 1 
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.
ScanStringEx.png
Figure 3
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.
editformatex.png
Figure 4
Refer to the LabVIEW Help for more information about format specifier syntax.

Comments, questions, feedback, criticisms?

Discussion forum

Send feedback