Activity 9-2: More String Parsing


You will create a VI that parses information out of a longer string by taking a subset of a string and converting the numeric characters in that subset into a numeric value.

1.

Build the front panel shown in Figure 9.27.

Figure 9.27. Front panel of the VI you will create during this activity


2.

Set the Password string control to display only asterisks by selecting Password Display from its pop-up menu

3.

Create the block diagram in Figure 9.28.

Figure 9.28. Block diagram of the VI you will create during this activity


String Subset Function

The String Subset function (Programming>>String palette) returns a subset of given length from the input string, according to the offset specified.

Scan From String Function

The Scan From String function (Programming>>String palette) converts a string containing valid numeric characters (0 to 9, +, -, E, and period [and sometimes a few others]) to a number.

Match Pattern Function

Match Pattern (Programming>>String palette) compares the user's input password string to a given password string. If there is a match, it is displayed; if not, the string indicator shows an empty string.

Empty String/Path? Function

Empty String/Path? (Programming>>Comparison palette) returns a Boolean TRUE if it detects an empty string from the match sub-string output of Match Pattern.

String Length Function

String Length function (Programming>>String palette) returns the number of characters in the concatenated string.

4.

Run the VI with the inputs shown. Notice that the string subset of "DC" is picked out of the input string. Also notice that the numeric part of the string was parsed out and converted to a number. You can try different control values if you want; just remember that strings, like arrays, are indexed starting at zero.

Also note how the Password string shows only "*****." Match Pattern checks the input password against a password string (which in this case contains the characters "password"), and then returns a match if it finds one. If it finds no match, it returns an empty string.

5.

Close the VI by selecting Close from the File menu. Save the VI in your MYWORK directory as Parse String.vi.




LabVIEW for Everyone. Graphical Programming Made Easy and Fun
LabVIEW for Everyone: Graphical Programming Made Easy and Fun (3rd Edition)
ISBN: 0131856723
EAN: 2147483647
Year: 2006
Pages: 294

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net