LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search string array and get the most updated file

hi, i was wondering if anyone can help me with this problem. i am working with labview 7.0

i have a directory of files.
i want to list the files from that directory, then search for the S/N of the device i want to get data from.
I am currenlty facing this issue..
it is currently get all the devices I found in the directory and my code only works for 1 file..not all
for instant..
if i have SN 434655.
there are 3 files for that SN in my directory..
1 on 5-31-2007
2 on 6-7-2007
3 on 8-29-2007

how do i simplified my search so that i will find the file for 8-29-2007 (which is the most up to date file).
thank you in advance!




Message Edited by krispiekream on 02-28-2008 03:21 PM
Best regards,
Krispiekream
0 Kudos
Message 1 of 14
(5,351 Views)
The File/Directory Info function (in the advanced palette) returns the modification time of the file. You can go over all the files in a for loop, index their times out of the loop and do an Array Max & Min on that to find the index of the file with the maximum time, which is the newest file.

___________________
Try to take over the world!
Message 2 of 14
(5,334 Views)
The File/Directory Info function (in the advanced palette) returns the modification time of the file. You can go over all the files in a for loop, index their times out of the loop and do an Array Max & Min on that to find the index of the file with the maximum time, which is the newest file.


do i need to do the mod time?
i can just get the number of files from the directory..
list them all..
normally when i list them..they follow the order in which it is arranged in my directory...
normally, the last would be the one..
but i dont know how to get the last of my array..
sorry i am fairly new to labview..
can you show me how to do that?

Best regards,
Krispiekream
0 Kudos
Message 3 of 14
(5,328 Views)

See below for how to get last element in an array.

But it is a really big assumption that the last file in your directory will be the latest.  It all depends on how the operating system orders the files.  Suppose an early file that was created is the most recent one to get modified?  It would be higher up in the directory list.



Message Edited by Ravens Fan on 02-28-2008 05:07 PM
Message 4 of 14
(5,321 Views)
thanks Ravens Fan

that method works..but yeah..i really can't assume that because i did and that was not the case..
maybe tst was right...
can you show me how to do it his way? or tst can you show me in a diagram?
\thanks
Best regards,
Krispiekream
0 Kudos
Message 5 of 14
(5,318 Views)
thanks tst and Ravens Fan..
I think your solution is good enough for me right now..
it seems to work for now...

another issue i have is this other part..

SN - my value is always -1
it is not the value i am looking for...
when SN= -1, therefore my search never finish because it always throw out the last element..
i know how to fix it...
when my program runs, the reading SN is 2 sequence after that...
is there any way to get around this?
just wondering..
thanks


Best regards,
Krispiekream
0 Kudos
Message 6 of 14
(5,307 Views)

Without seeing the code, I'm not sure what the problem is exactly, but if you have an invalid output, you can put a case structure around the entire code and check the value of the SN to decide whether to run the code or not.

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.


___________________
Try to take over the world!
Message 7 of 14
(5,294 Views)
i dont know if i am allow to post up the codes.
i think what i am doing is currently work...
i have this code now..

how do i stop my while loop?
i want to stop when currentpos = 44
also if S/N = -1, i want to skip it and not use it in my search?
is that possible..?
thanks

Best regards,
Krispiekream
0 Kudos
Message 8 of 14
(5,281 Views)

Hi krispiekream,

why do you need the while loop? If you only want to get the latest file with your serial number try this code.

Mike

Message 9 of 14
(5,269 Views)
great...that works too
thanks

Best regards,
Krispiekream
0 Kudos
Message 10 of 14
(5,253 Views)