LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find first non zero value from the numeric value or string?

Hiii, Every body
 
          I have one numeric indicator in which some valuse is coming with the decimal value, lets say 0.00013, now i want to find the first non-zero value from this numeric indicator, then what should i do to do so? i have converted it in the string, but i could not find any method to find first non-zero value from that string or either from the numeric indicatorSmiley Sad????
 
      Can you please help me, how to do it? i have attached the vi and write all the description inside.
 
Thanks in Advance,
Nisahnt
0 Kudos
Message 1 of 10
(3,938 Views)

You can use the Match Pattern function with [1-9] as the expression. The help for Match Pattern includes many examples on how to use it.

Message Edited by Dennis Knutson on 05-10-2006 07:56 AM

0 Kudos
Message 2 of 10
(3,933 Views)
Hiiiii, Dennis
 
                     Thanks for the prompt reply and i ve got what i want, thanks.
 
                    But can you explain me what this function will do? will it find the offset of the first number from 1-9?
 
Thanks,
Nishant
0 Kudos
Message 3 of 10
(3,921 Views)

Anybody wanna see the REALLY ugly solution?

Anyway, experience tells me there's a fair chance that this isn't really what you're after. What's your end goal? LabVIEW has some surprising answers: the trick is in knowing the correct question!!

 

0 Kudos
Message 4 of 10
(3,911 Views)

As the help explains:

offset past match is the index in string of the first character of after substring. If the function does not find a match, offset past match is –1. The offset input and the offset past match output might be equal when the empty string is a valid match for the regular expression. For example, if regular expression is b* and the string input is cdb, offset past match is 0. If string is bbbcd, offset past match is 3.

0 Kudos
Message 5 of 10
(3,901 Views)
Just convert it to an exponential string and take the first character ;).
 

Message Edited by altenbach on 05-10-2006 08:00 AM

Download All
0 Kudos
Message 6 of 10
(3,902 Views)


@altenbach wrote:
Just convert it to an exponential string and take the first character ;).

 

This only works for positive numbers of course. If the number is negative, grab the second character.

Message Edited by altenbach on 05-10-2006 08:26 AM

0 Kudos
Message 7 of 10
(3,886 Views)

Hiii, Altenbach

             Thanks for the reply.

             Actually i made a mistake when i wrote the initial question in the post, i want the position offset of the first nonzero value, can you please do it for me? and with considering if number is negative...

Thanks,

Nishant

0 Kudos
Message 8 of 10
(3,867 Views)
Use Dennis's solution and connect to the offset output of the "match pattern" function. You should easily be able to calculate the position you need.
0 Kudos
Message 9 of 10
(3,865 Views)

Hiii, Altenbach

                   Thanks for the prompt reply, simply i use your idea in Dennis's solution and i ve got what i want.

Thanks,

Nishant

0 Kudos
Message 10 of 10
(3,861 Views)