Skip to content Skip to navigation

Connexions

You are here: Home » Content » String Functions

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of 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.

      What are tags? tag icon

      Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

    • External bookmarks
  • E-mail the author
  • Rate this module (How does the rating system work?)

    Rating system

    Ratings

    Ratings allow you to judge the quality of modules. If other users have ranked the module then its average rating is displayed below. Ratings are calculated on a scale from one star (Poor) to five stars (Excellent).

    How to rate a module

    Hover over the star that corresponds to the rating you wish to assign. Click on the star to add your rating. Your rating should be based on the quality of the content. You must have an account and be logged in to rate content.

    (0 ratings)

Lenses

What is a lens?

Definition of 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.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

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.
  • National Instruments display tagshide tags

    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.

    Click the tag icon tag icon to display tags associated with this content.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

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.

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: 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:
    Table 1
    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.

Figure 1
Figure 1 (ConfigBuildText.png)

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.

Figure 2
Figure 2 (BuildTextEx.png)

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.

Figure 3
Figure 3 (ScanStringEx.png)

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.

Figure 4
Figure 4 (editformatex.png)

Refer to the LabVIEW Help for more information about format specifier syntax.

Comments, questions, feedback, criticisms?

Send feedback