Discussion:
Array of Boolean to String
(too old to reply)
super-neuron
2008-08-05 21:10:07 UTC
Permalink
Hello All,
 
I have a small coding challenge that has been whipping me all day.   I have a 19 element boolean array that I would like to convert to a string without delimiters("0000000000000000000").    Within a for loop I use a "Select" followed by a "Number To Decimal String."   Once outside the loop then use the "Array To Spreadsheet String" function on the indexed output.    I tried using a blank delimiter input on the "Array To Spreadsheet String" function but that reverts back to tabs.   Bummer.   I'll keep plugging away trying different functions and constructs, but this feels harder than it really should be.    Any fresh prespectives would be greatly appreciated!
 
Sincerely,
Zach


array_of_clusters_to_XLS (SubVI).vi:
http://forums.ni.com/attachments/ni/170/346886/1/array_of_clusters_to_XLS (SubVI).vi
jmcbee
2008-08-05 21:10:09 UTC
Permalink
Hello,You could try something like this:<img src="Loading Image..."> Message Edited by jmcbee on 08-05-2008 03:00 PM


Boolean Array to String.PNG:
http://forums.ni.com/attachments/ni/170/346891/1/Boolean Array to String.PNG
corys
2008-08-05 21:10:09 UTC
Permalink
Beat me to it, and mine's pretty much the same...but here it is, since I spent the time taking the picture anyway :P<img src="Loading Image..."> Message Edited by corys on 08-05-2008 04:02 PM


BinaryString.PNG:
http://forums.ni.com/attachments/ni/170/346893/1/BinaryString.PNG
smercurio_fc
2008-08-05 21:10:09 UTC
Permalink
Even simpler:<img src="Loading Image..."> Message Edited by smercurio_fc on 08-05-2008 04:01 PM


Example_VI.png:
http://forums.ni.com/attachments/ni/170/346892/1/Example_VI.png
jmcbee
2008-08-05 21:10:10 UTC
Permalink
I never knew that concatenate strings worked that way on arrays, this is a very useful thing to know! Thanks Smercurio!
altenbach
2008-08-05 21:10:10 UTC
Permalink
super-neuron wrote:
&nbsp; I have a 19 element boolean&nbsp;array that I would like to convert to a string without delimiters("0000000000000000000").


"Boolean to 0,1" - &gt; "Number to decimal string" -&gt; "concatenate array". No loop needed.
&nbsp;
&nbsp;<img src="Loading Image...">
EDIT: looks like smercurio beat me to it. :DMessage Edited by altenbach on 08-05-2008 02:09 PM


BooleanArrayToText.vi:
http://forums.ni.com/attachments/ni/170/346896/1/BooleanArrayToText.vi


BooleanArrayToText.png:
http://forums.ni.com/attachments/ni/170/346896/2/BooleanArrayToText.png
corys
2008-08-05 21:40:05 UTC
Permalink
Aha...didn't realize the concatenate string worked like that. It is quite handy! (So is reading the context help, I now realize :P )
altenbach
2008-08-05 21:40:05 UTC
Permalink
Just for kicks, here's another "no loop" version. Does not even use "concatenate string" :D
&nbsp;
<img src="Loading Image...">
&nbsp;
(This will not work if you have more than 32 booleans). I reversed the input array to give the same reuslt as the other solutions.
&nbsp;
&nbsp;Message Edited by altenbach on 08-05-2008 02:16 PM


BooleanArrayToText2.png:
http://forums.ni.com/attachments/ni/170/346899/1/BooleanArrayToText2.png


BooleanArrayToText2.vi:
http://forums.ni.com/attachments/ni/170/346899/2/BooleanArrayToText2.vi
corys
2008-08-05 21:40:06 UTC
Permalink
Gah...I *knew* there was a way to do it like that (Altenbach / Centerbolt). For some reason I kept missing a little something, so just went with the next train of thought that came to me on how to do it.
centerbolt
2008-08-05 21:40:05 UTC
Permalink
The simplest way I know how.&nbsp; Note that it will pad with leading zeros when necessary to make sure you get all 19 bits/characters.
&nbsp;
<img src="Loading Image..."> Message Edited by centerbolt on 08-05-2008 05:15 PM


Binary Array to String1.PNG:
http://forums.ni.com/attachments/ni/170/346898/1/Binary Array to String1.PNG
smercurio_fc
2008-08-05 21:40:07 UTC
Permalink
And to do it so it's not fixed to 19 bits:<img src="Loading Image..."> Well, this is fun. :smileyvery-happy: :smileyvery-happy: OK, back to work.Message Edited by smercurio_fc on 08-05-2008 04:23 PM


Example_VI.png:
http://forums.ni.com/attachments/ni/170/346904/1/Example_VI.png
super-neuron
2008-08-06 14:40:08 UTC
Permalink
Wow... What a response!&nbsp; :smileyvery-happy:
&nbsp;
Thanks to everyone who posted!
&nbsp;
Sincerely,
Zach
altenbach
2008-08-07 23:40:05 UTC
Permalink
While investigating these issues, I noticed a problem with incorrect coercion dots in LabVIEW 8.5.1. I have written a bug report:
&nbsp;
<a href="http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;view=by_date_ascending&amp;message.id=6325#M6325" target="_blank">http://forums.ni.com/ni/board/message?board.id=BreakPoint&amp;view=by_date_ascending&amp;message.id=6325#M6325</a>
&nbsp;
(Please discuss any related problems here in order not to&nbsp;violate the bug thread rules). :)
&nbsp;
&nbsp;
Ravens Fan
2008-08-08 03:10:05 UTC
Permalink
Christian,
In your bug thread message, your second image doesn't appear.&nbsp; It is only the box with red X.&nbsp; Its source is <a href="Loading Image..." target="_blank">http://forums.ni.com/attachments/ni/beta5/4862/1/Coerced.png</a>
Is that a restricted message board?
altenbach
2008-08-08 04:40:04 UTC
Permalink
Sorry, about that. It seems something went wrong. :o
&nbsp;
Here's the attachment again:
<img src="Loading Image..."> Message Edited by altenbach on 08-07-2008 09:24 PM


Coerced1.png:
http://forums.ni.com/attachments/ni/170/347748/1/Coerced1.png

Continue reading on narkive:
Loading...