Skip to content Skip to navigation

Connexions

You are here: Home » Content » Create String VI

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.

Create String VI

Module by: National Instruments

Summary: In this exercise, the objective is to use the Build String, Match Pattern, Scan from String, and String Length functions. Complete the following steps to build a VI that converts a numeric value to a string, concatenates the string to other strings to form a single output string, and determines the output string length. The VI also matches a pattern in a string and converts the remaining string to a numeric value.

Exercise 1

1.a) Front Panel

  1. Open a blank VI and build the front panel shown in Figure 1. Do not add labels for the comments; they are shown for informational purposes only.
    Figure 1
    Figure 1 (buildstring.png)
    Use the following hints to build the front panel:
    • Right-click String 2 and select '\' Codes Display from the shortcut menu. The text typed in String 2 is Volts DC: +1.26E+1. As shown using Codes display in the front panel above, there are two spaces after the colon (\s\s), and the text ends with a carriage return (\r\n). You may see only a \r or a \n for the carriage return.
    • Change String Length and Offset Past Match to 32-bit signed integer (I32) representation.
    • After entering text in the controls, select Operate>>Make Current Values Default to set the text as the default values of these controls.

1.b) Block Diagram

  1. Build the block diagram shown in Figure 2.
    Figure 2
    Figure 2 (buildstringbd.png)
    1. BuildIcon.png Place the Build Text Express VI, located on the Functions>>Output palette, on the block diagram. This function converts Number to a string. The Build Text configuration dialog box appears.
      1. Type %Header% %Number% %Trailer% in the Text with Variables in Percents text box to create three variables. The variables appear in the Configure Variables section.
      2. Select Number in the Variable section.
      3. In the Variable Properties section, select the Number option, set the Format to Format fractional number. Place a checkmark in the Use specified precision checkbox and set the Precision to 4. Leave the Header and Trailer variables in the default state.
      4. Click the OK button to close the dialog box.
    2. strglengthicon.png Place the String Length function, located on the Functions>>All Functions>>String palette, on the block diagram. This function returns the number of characters in Result.
    3. matchpaticon.png Place the Match Pattern function, located on the Functions>>All Functions>>String palette, on the block diagram. This function searches String 2 for a colon (:). Right-click the regular expression input, select Create>>Constant from the shortcut menu, type a colon (:), and press the <Enter> key on the numeric keypad. You also can click the Enter button on the toolbar to complete the entry. Do not use the <Enter> key on the main keyboard because in this case it adds the return character to the search expression.
    4. scanfromstrgicon.png Place the Scan From String function, located on the Functions>>All Functions>>String palette, on the block diagram. This function converts the string after the colon to a numeric value.
    5. Complete the block diagram as shown in Figure 2.

1.c) Icon & Connector Pane

  1. Display the front panel and create an icon and connector pane so you can use this VI as a subVI later in this course. Refer to the lesson on Modular Programming for more information about creating icons and connector panes.
    Figure 3
    Figure 3 (createstringconpane.png)
  2. Save the VI as Create String.vi in the C:\Exercises\LabVIEW Basics I directory. You will use this VI later in the course.

1.d) Run the VI

  1. Change the values of the front panel controls and run the VI. The VI concatenates Header, Number, and Trailer into Combined String and displays the string length. The VI also searches String 2 for a colon, converts the string following the colon to Number Out, and displays the index of the first character after the colon in Offset Past Match.
  2. Save and close the VI.

Comments, questions, feedback, criticisms?

Send feedback