Connexions

You are here: Home » Content » Create String VI
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.

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.

Problem 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
    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
    1. 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. 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. 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. 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
  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?

Discussion forum

Send feedback