From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

initializing a string as NULL

I am reading an array and comparing the values within a range and I would like capture all of the

elements in the array where the values that do not fit into the range.

 

I am able to do this with the following but I would like to initialize the string first as a null because

every time I run this the field "bad channels" does not clear on my front panel. 

 

 

Is there an easy way to initialize my "bad channels" string before the loop?

 

thanks  

 

badchannels1.jpg

0 Kudos
Message 1 of 8
(4,100 Views)

Initializer terminal is on the bottom of the feedback node. You can also right click it and Move Initializer One Loop out to initialize it on loop start, not on VI first call

Message 2 of 8
(4,089 Views)

A couple more things:

 

Move feedback node out of the Case structure. Otherwise if your last value is good, bad channels will be empty.

There is In range function in comparisons Palette - it will replace 2 comparisons and OR

Message 3 of 8
(4,085 Views)

ahh, a diagram is worth a 1k words

accumulate strings.png

Message 4 of 8
(4,077 Views)

My personal preference (and one preferred by my students, who find Feedback Loops tricky to reason with) is to be as straight-forward as possible.  According to the Original Poster, values from 3000 through 4500 are OK, the rest are Bad.  So here is code that (to me) says this Loud and Clear:

Bad Channels.png

First, the "initialization" step is clear -- an empty String.  Next, the criterion for "what to do when you get something that does not fall into the "Good" range (hence the False case) is to concatenate (using Format into String) the Index onto the "Bad" string.  If nothing is Bad, then the empty string emerges at the other end.  True, you don't "see" the True case here, but if you need it, you can put in a free label that says "We do nothing if we are In Range".

 

Bob Schor

0 Kudos
Message 5 of 8
(4,041 Views)

Couldn't help but to join the fun...

 

This might be a little more memory efficient (haven't ran any tests to prove it) by not having to constantly allocate strings.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(4,000 Views)

Crossrulz, 

     I'm giving you a Kudo, mostly for the poorly-named "Array to Spreadsheet String" function (which I hadn't noticed before).  I would have named it "Array to Delimited String", myself.  The Virtue to this function is that it gets rid of the "trailing comma", which is a nuisance otherwise ...

 

Bob Schor

0 Kudos
Message 7 of 8
(3,994 Views)

Bob_Schor wrote:  the poorly-named "Array to Spreadsheet String" function (which I hadn't noticed before).  I would have named it "Array to Delimited String", myself.

Back when that fucntion was created, it matched what everybody thought of for a "spreadsheet file" (usually tab or comma delimited data).  Excel came along and changed that.  So, yes, the name is not quite right in today's terms.  But there is a reason it was named that.

 

Please return to your regularly scheduled program...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 8
(3,944 Views)