LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search string in Array

I have one 1D array in that array the elements are started like 04_02_26LS1004(format is yy_mm_ddserialnumber).I Dont know the array size. It may go more than 60000. I want to search the elements which are all matching for the first 8 characters(yy_mm_dd).I don't need to compare one element by one element using for loop.Please Suggest.

with regards

R.sathiyanarayanan
0 Kudos
Message 1 of 6
(3,610 Views)
Try using this vi. I think this is what you are looking for. Hope this helps
BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 2 of 6
(3,610 Views)
Here's a way to do it. The first section just sets up some dummy data. The second part results in a 2D array where each row is an array of matched strings based on the first 8 characters of the string. The last part indexes this 2D array and truncates each matched string array to eliminate empty string elements. Inside the blank sequence structure is where you would perform the action(s) you want on each matched string array.

This is not very fast. Depending on the randomness of the dates, it could take up to 1 minute to process (using a P4 CPU). The more dates that match, the less time to process.

Dave.
==============================================

0 Kudos
Message 3 of 6
(3,610 Views)
Dear Sir,

Thanks for your help. Actually i wanted to find the matched elements without using the for loop. Since if i use the for loop in my application gets slowdown for a minute. Now i got the solution from Forum by inserting the lowest & Highest values in the array (For example,if i wants 04_02_26, My serial numbers will start from LS0000, so i will add the lowest ASCII value 04_02_26AA0000 & the Ascii maximum 04_02_26ZZ9999)and sorting the 1D array. Now i will get the index of the known Lowest(04_02_26AA0000) and Highest(04_02_26ZZ9999). Using that i will split the array and i will get the required portion.
0 Kudos
Message 4 of 6
(3,610 Views)
Hi, it's me again,

I just wanted to add that you maybe need to be careful with upper and lower-case letters. Since the upper-case letters are lower in the ASCII table than the lower-case letters, zz9999 is the last possible match, not ZZ9999. If all your letters are upper-case, this won't make any difference, but just in case.....

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 5 of 6
(3,610 Views)
Dear Shane,

Thank you for your comments.I verified with my requirement and it is working.

Sathiyanarayanan
0 Kudos
Message 6 of 6
(3,610 Views)