LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from Dat file

Hi All,
 
I have to currently work with an application in which i have to read the data from a dat file.
 
I am attaching a sample of the format of the file.
 
I have to select a name from the ring(combo box) and the combo is accepting names from the dat file.
 
The dat file contains names like MCP-SSM,AEN-SSM-1...

What i have to do is,from the dat file i have to select those names starting with AEN- (ie,AEN-SSM-1,AEN-SSM-2,AEN-SSM-3,AEN-SSM-4)and insert into the combo box.

I havent worked with dat file.so i dont know how to read from that and select paricular text.

Can anybody help me?

If possible i have to do one more thing.I have to extract the fields that is contained in each AEN.

ie,if AEN-SSM-1it contains SS1,SS2,SS3,SS4 ,SS5 and its corresponding values.

700,594,490,385,280

I want to extract these also.

Thanks in advance

 

 

 

 

 

 

 

 

 

0 Kudos
Message 1 of 6
(3,637 Views)
Hi user_1,

it seems your mysterious .dat-file is nothing more than simple text.
So read in as text file. In the resulting string you have to search for 'AEN-' and, when found, get the next 5 characters (like 'SSM-1'). Now you have the name of the setting. In every AEN-section you have 5 values: search for 'SS', get next number (=index of value), get next number (=value).
This can all be done by using standard string functions!


Message Edited by GerdW on 06-01-2007 02:01 PM

Best regards,
GerdW


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

THANK U SO MUCH FOR UR REPLY SIR.

Actually i hav to deal with the dat file itself as it is common for many softwares.

So there is no way for me to replace the dat file by a text file.

String serching is ok.But how to manipulate the dat file (open,read an close the file).

I havent worked with dat file before.

So can you pleases tell me a solution for this.

Thanks once again

0 Kudos
Message 3 of 6
(3,603 Views)
Hi user_1,

your file is a text-file even without file extension '.txt'! So use standard functions (like 'Read/Write Characters from/to file' in LV7.1) to read your dat-file.

The filename isn't important, the content is important. You can rename your file to whatever you like and it will still be a text-file...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(3,592 Views)
user,
 
To answer you question, you need to simply open the file using the Open/Create/Replace File VI, then using the Read Text File VI, you will get a string of the entire file's contents.
 
From this string, you can search and parse the string as you see fit.  Search for your delimiter, then take some of the string before or after your delimiter.  It's really all up to you how you want to break down the string.  If you are familiar with parsing text in any language, you shouldn't have too much trouble.
 
Finally, when you have the strings you want, you simply create an array of those strings and pass it into the Strings[] property node of the text ring that you want to use.  To create the property node, right click on your text ring on the block diagram and select Create>>Property Node>>Strings[].  You will then need to right click on the property node and select Change All to Write to change the enumeration of the text ring.  This property node can be accessed at any time to dynamically change your text ring.
 
I have attached a screenshot of a very simple parser that enumerates a text ring.  I hope that it helps.
 
Brian Coalson

Software Engineer
National Instruments
Message 5 of 6
(3,576 Views)
Thank you so much for the replies.
 
Problem solved because of the help.
 
Thanks once again.
0 Kudos
Message 6 of 6
(3,524 Views)