LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Break down a string into individual parts to search a database

Solved!
Go to solution

Hello all,

 

I'm relatively new to LabVIEW, but I will try to explain the problem I'm having the best I can. Here's the problem:

 

1. Given a part number that is broken down like this: 0 0 0 0 . 0 0 0 0 0 . 0 0 0 0 0 0 <0> . 0 0 <0> The zeros enclosed in brackets mean they may or may not be there, depending on if an option is included in the part.

2. When a person enters a part number, I want LabVIEW to take the first two numbers, look in one table in a database.

3. Then, with the next two numbers, search a separate table in the same database and match these numbers.

4. Use the following three numbers after the two previously searched and find these in a different table in the same database.

 

This process continues until there are no numbers left. I want the user to be able to enter, for example 1234.56789.12345.67 and LabVIEW can say "OK, this part is from Series X, with a length of X, from drawing X, etc." Each set of numbers correspond to a feature of the part. All the tables are in the same database.

 

Can anyone point me in the right direction? I do have the database connectivity tool and I have successfully connected to the database. I used the examples within LabVIEW and can successfully complete the "Read All Data" VI example. What I need now is a way to search this database.

 

Thanks everyone!

0 Kudos
Message 1 of 38
(3,367 Views)

Well, you have to questions in one here it seems:

 

a) String handling:

You should look into "Scan From String" and, as requirement for it, regular expressions.

 

b) Database Queries:

You should learn, how to formulate SQL Queries.

 

Since you are working with LV, you should also search the LV help for the quoted functions.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 38
(3,351 Views)

Norbert,

Thanks for your reply. I'll look further into it per your suggestions. Hopefully I can come up with something and post it here to get some feedback.

 

Thanks again,

Chris

0 Kudos
Message 3 of 38
(3,344 Views)

I'm still not sure on how to even begin dividing the string which is all numbers into separate pieces. Let me try to explain better by showing what I mean. I'll include a divider to show where I need to separate the string.

 

 0 0 0 0 . 0 0 0 0 0 . 0 0 0 0 0 0 0 . 0 0 0

|     |    |  |       |     |  |    |     |       |  |       |

 

So, after the string is separated it would be

 

00

00

000

00

00

00

000

000

 

From these separate strings, I want to search a database. So, the first two digits would search in the first table, the second two digits in the second table, and so on. Anyone?

0 Kudos
Message 4 of 38
(3,331 Views)

If I understand your Q

 

String parsing can be tricky but LV has lots of tools to go about it.

Make a test wrapper VI with string input and outputs

 

In the VI Use all the string functions you think might bre helpful to get the result you want for each parsing.

Test each one to find the best for each field.

Nice thing about LV and string parsing is you can see results of a test immediately and try all sorts of stuff.

Good starting candidates are

 

String subset

Match Pattern

and

Scan from string

If the numbers are spaced with spaces don't forget to remove whitespace after each iteration  in your loops as you progress through a string.

 

You might be able to get fancy and use a while loop with a shift register to parse or copy ions of the string for each "thing" you are looking for without really affecting the original string too.

Its all there for the testing.

 

 

 

0 Kudos
Message 5 of 38
(3,324 Views)

Thanks for your reply. This is as far as I've gotten:

 

code

 

When I run the VI, it separates the strings as desired. However, it omits the leading zeros. This isn't good because the database that I'm going to be querying needs the leading zeros. Also, I need the periods in the part number, but everytime I run it with the periods I get the error: The input string does not contain data in the expected format.

 

frontpanel.jpg

0 Kudos
Message 6 of 38
(3,319 Views)

You need to stay in the text domain. I don't know why you are doing what you are doing. You'll end up having to convert the numbers back to a string to use in an SQL query.

 

 

0 Kudos
Message 7 of 38
(3,315 Views)

The part numbers are all digits. I need to break the numbers up, or so I thought, because each "set" of numbers corresponds to a table in a database. NYC, is there a different way to do this? Thanks for your help

0 Kudos
Message 8 of 38
(3,311 Views)

break up the long string into substrings using String subset function

 

 

0 Kudos
Message 9 of 38
(3,299 Views)

Try this. (I did not convert the strings to numbers but your SQL query will end up being a string anyway.)

 

Parse SN.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 38
(3,296 Views)