LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter filenames according to specific strings within and find non-matches

Solved!
Go to solution

Hi all,

 

I have a folder containing files which i would like to filter in order to obtain the next serial number which does not exist yet. The filenames are built with the format [serial number]_[date and time]. Sometimes there are multiple data files with the same serial number but that is fine and should be ignored.

 

In my sample vi (which does not work because each serial number is being matched to a single element of the array each time so there will never be correct matches), my goal is to compare the current serial number to every element in the filename array, if there is a match, to ignore it, increment the serial number and repeat (and stop when it reaches a certain maximum serial number) until it finds a serial number with no matches (which means the file does not yet exist) and gives that out to the user.

 

I have tried using a for loop as well but I couldn't get it to work too. The existing filename array is also bound to be larger than the quantity index so I also have to figure how to continue iterating according to the larger array.

 

I know I'm missing a certain loop logic here but I can't quite get it to work so any solution/tips are welcome.

 

Thank you in advance!

 

SampleGetNextFile.png

 

 

0 Kudos
Message 1 of 6
(1,115 Views)
Solution
Accepted by topic author nikvl

Hi nikvi,

 


@nikvl wrote:

I know I'm missing a certain loop logic here but I can't quite get it to work so any solution/tips are welcome. 


Please:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,101 Views)

Hi GerdW,

 

thank you for the prompt reply!

 

Unfortunately that also did not work.

When I ran your code, it returned 25900441 as a result but it should be returning 250900447 since no file with that name exists yet.

0 Kudos
Message 3 of 6
(1,088 Views)

Oh wait I found a typo in my serial numbers. 

I changed the output wire of the found serial to before the addition function +1 to get the right serial number.

 

Thank you!

0 Kudos
Message 4 of 6
(1,078 Views)

Hi nikvi,

 


@nikvl wrote:

I changed the output wire of the found serial to before the addition function +1 to get the right serial number.


 You're right, you need to take the serialnumber value before incrementing to get the right output. (Or decrement after the outer loop.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,049 Views)

You can use some Decimal String to Number behaviours to simplify the code.

Yamaeda_0-1789112635872.png

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(617 Views)