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!
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.
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
Hi ukbaisdumb
If the format of the string will be same DP -0.123mmH2O then you can use the following method
regards,
shrek
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"...
Incase if you need the units too...
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.