LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PARSING

HI is any suggestion or any site on parsing tex files.

 

 

Im just trying to parse

 

 CHILLER 22

 

0 Kudos
Message 1 of 18
(5,630 Views)

For reading text files I usually use the regular expression functions in CVI.

 

You can use RE's to search the text file for items of interest.  The NI RE implementation is not particularly good - it won't parse past a linefeed as I recall.

 

You may be able to find an RE library in C on the web that does a better job than CVI.

 

Menchar

0 Kudos
Message 2 of 18
(5,629 Views)

What are RE's?

 

0 Kudos
Message 3 of 18
(5,626 Views)
RE = Regular Expression. The CVI instrument for using regula expressions can be found in toolslib\toolbox folder (regexpr.fp).


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 18
(5,623 Views)

is there an example in cvi to loop at , where in the are are opening text files and parsing them.

 

or if you have an example can you send it to me.

 

i just need some where to start. 

0 Kudos
Message 5 of 18
(5,618 Views)

If your parsing needs are that simple, you can just use the ANSI C sscanf() function.  sscanf() returns the number of items found, so you can use that return value for a simple error check.

 

char command[256];

int parameter, items;

 

char cmd_line[] = "CHILLER 22";  // real program will get this string from somewhere else

 

// read the command, expecting 2 items 

items = sscanf(cmd_line, "%s%d", command, &parameter);

 

if (items != 2)

  printf("Syntax error in line %s\n", cmd_line);

 

Your last question on reading from a file is starting to duplicate your post here: http://forums.ni.com/ni/board/message?board.id=180&message.id=42661&jump=true

 

Message Edited by Al S on 08-26-2009 02:06 PM
0 Kudos
Message 6 of 18
(5,617 Views)
thats what im doing uing it for a real world code. because im going to call the text file in to a text executive to lunch my gui.
0 Kudos
Message 7 of 18
(5,608 Views)
i would eventually suggest to first define exactly what the syntax of your file will be. then document this syntax: do a search for BNF and try to express your syntax using this notation. during this process, you may encounter some problems which will force you to refine your syntax. once this is done, it is very easy to convert your BNF syntax into a parser, using either RE or a hand written parser or any other tool (there exists some parser generator software which output C code for a BNF input syntax).
0 Kudos
Message 8 of 18
(5,584 Views)
WHAT IS RE AND HOW DO YOU GET TO IT
0 Kudos
Message 9 of 18
(5,582 Views)

ok i got the program to work, where it will interpret the text file. now my question is how can i get the that text file associate with the ini file.

 

because what is going to happen i have program that has a gui and it speaks to a device. what i want to do is have that text file lauching the same gui i have.

 

because the engineer wants to be able to edit the temperature from the text file. so how can i make that happen. what will be my starting point.

 

im going to post my project soyou can see what im talking about

 

0 Kudos
Message 10 of 18
(5,580 Views)