LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

display timestamp from text file

I have yet another time related problem. I have a timestamp like this 04/20/04 15:02:34, coming in the 0 place of a text file. After the timestamp in the text file there is data that is comma delimited. The text file is being appended every fifteen minutes with data. I am converting the string to an array to plot the data. I also have the string (prior to conversion to array) being output onto the front panel. Is there anyway to just output the last timepoint of the string? (ie the last line of the string). I would then like to make a jpeg of the string indicator. I should use "write to jpeg" for this right.

Thanks for any suggestions.

Matt
0 Kudos
Message 1 of 5
(2,764 Views)
There's a couple ways that you can get the last line of the string. If it's in the array, then it's simply a matter of using the Index Array function to get the last element. Use the Array Size, subtract 1 from it and use that as the index value. To work with the raw string, you could use the Reverse String and get the first x number of characters using String Subset. If the time stamp is always the same length, this should work fine. Do another Reverse String to have the time stamp read correctly. If the time stamp is not a constant length, you could use Match Pattern on the reversed string. Use a carriage return, line feed, or whatever is the line terminator, as the regular expression. The before substring output should be the last line. You would ag
ain have to reverse it to get it to read correctly. See the attached example (LV 6.1)
0 Kudos
Message 2 of 5
(2,764 Views)
Dennis:
you're a awesome. I used the reverse string and sring subset works great.


matt
0 Kudos
Message 3 of 5
(2,764 Views)
I added another approach to Dennis's suggestions. This approach better utilizes the power of the match function. I also included a sample jpeg writer. This is in LV7. I work on a MAC and I haven't figured out how to save as a 6.1 vi, probably because it is not possible. I attached an RTF document with a picture of the diagram in the event you don't have access to LV7

-jayme
jc
Mac 10.4
LV7.1
CLD
Download All
0 Kudos
Message 4 of 5
(2,764 Views)
Oops, I committed a bad programming sin. I forgot to close my control reference to the string. If you do that, the code should be acceptable.

-jayme
jc
Mac 10.4
LV7.1
CLD
0 Kudos
Message 5 of 5
(2,764 Views)