LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to get numeric result from 'search and replace' string function

hii
i am using search and replace function to get output.my output is of form ' *X0123.3 ' .here i am replacing the term *X01 with space because i need only 23.3 as a result.but i am unable to get that out in the output indicator.i used lot of functions like string to number and so on but i am getting output as zero .can you please suggest me wt to do.i am attaching a copy of my file.
0 Kudos
Message 1 of 5
(2,768 Views)
Not sure what your problem is since the bit of code that you're talking about works just fine. See attached for the excerpted section. It seems like you're just chopping off the prefix to the response. If that's the case you can just use the Split String function or the Match Pattern function. There's no need to do a Replace String. See attached VI.
0 Kudos
Message 2 of 5
(2,754 Views)
 I agree with the other poster that your code appears to be ok, and the parse sting should be an easy fix.  Have you verified that you are getting a response from the instrument, and get something in the read command and result string indicators that you have??

I would also suggest putting in a VISA close at the end of the read, to make sure that the serial connection terminates properly.  Also, it is good practice to wire through your error so that you will no have parts of your vi excecuting if there is an error.

Kenny
Kenny

0 Kudos
Message 3 of 5
(2,747 Views)

Your problem is the fact that you are converting it to an integer, thus loosing the fractional part. You need to use "Fract/Exp String To Number" instead and create a DBL so yor data is 23.3 instead of 23.

You also don't need to manipulate the string if the initial part is of constant lenght. Just use the offset input as in the figure below. 😄

 

 

Message Edited by altenbach on 07-31-2006 07:02 AM

Message 4 of 5
(2,745 Views)
altenbach,  good point about the fractional conversion. I was so fixated on the use of the "Search and Replace" function, the use of which made no sense to me that I completely overlooked the actual number that was being converted. In my example you simply got 23.

Also, thank you for pointing out use of the "offset" input as a short-cut. Sometimes old habits refuse to die, no matter how long one has been programming in LabVIEW.
0 Kudos
Message 5 of 5
(2,713 Views)