11-10-2009 12:43 AM
Hi all,
I have a beginner's question. I am collecting some data from a micromanometer through labview. The input is through a serial RS232 port in ASCII format. Using one of the example VI viz, "Basic serial read and wirte" I see the data coming in the following way:
DP -0.123mmH2O
What I would like to do is now sort out the above string into just its numeric part and save it as a text file or table for post processing. I tried using the scan from string function but the final output i get is mmH2O if i scan it twice. Can please anyone help me find a solution.
Thanks for reading the post!
11-10-2009 12:48 AM
Have you tried the functions match pattern or match regular expression?
Check in context help and LV help about these functions.
These will help you to solve your problem.
11-10-2009 04:55 AM
Regular expressions are difficult (but not too difficult to make their value worth the effort); here's a reference I always use.
\- searches for the negative sign
{0,1} says to take it if you find it, but don't worry if it's not there (find zero or one of them)
[0-9] is a character class that will return a number
* says to take all that you find
\. looks for the decimal point
11-10-2009 04:57 AM
Hi ukbaisdumb
If the format of the string will be same DP -0.123mmH2O then you can use the following method
regards,
shrek
11-12-2009 02:20 AM
11-12-2009 02:54 AM - edited 11-12-2009 02:56 AM
Hi ukbaisdumb,
use ScanFromString this way:
It's as simple as it looks like... Search the context help for the different format codes!
In case the "DP" in front of the number can change: split the string at the " " (space) and scan for "%f"...
11-12-2009 03:41 AM
Incase if you need the units too...
11-26-2009 10:21 PM
Further to the problem, now I am reading the string from a VISA read block gathering input from a serial port, which is connected to a pressure measuring instrument. I have used the idea given in the example file of "basic serial read and write.vi" to read the input. Any suggestions as to how I should be doing this?
Thanks.