LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to invert a binary string array?

Hello,
I have an array or binary strings that may be as large as 240 elements.  All I need to do is invert the bits and and keep them in a string array.  Also the array can have a varied amount of elements but no more than 240 and they can start in any index value.

I was trying to convert the array to a boolean array and then invert it and convert it back to a string array with no luck.  Attached is my vi.  Thank you
0 Kudos
Message 1 of 4
(3,646 Views)

Could you give us your definition of "binary string array"?

Does each element have exactly one character tha can be either 0 or 1? In this case you could simply do something like in the image (the otehr case would be called "1" and have a 0 in it)..

When you attach an example, please always place some typical data in the controls, make current values the default, then attach the VI. This will make it much clearer what kind of data you're having. Why is your code inside a loop without any wait statement. It is just doing the same calculation over and over again.

Message Edited by altenbach on 09-29-2006 09:38 AM

Message 2 of 4
(3,639 Views)
Hi lfoitek,

let me explain what you actually did:
You added all the array items into one string, then interpreted this string as one number represented in binary. (the DBL)
Then converted this number into a U32 (the conversion dot) and then converted this into an array of booleans
Then you search the string array for the first 0 or 1 and at that point insert a boolean into the array of boolesn.


This makes no sense. The two arrays (boolean and string) have no connection what so ever.

What you should do (i'm just guessing):
Use a for loop to go through the array of strings;
Inside this array convert the string into an array of U8 (this is a function)
XOR this array with a U8 value of 255 this will invert the bits!!!!!
Convert the array of U8 into a string
Auto index the for loop

Ton

The link to the LabVIEW Learning Center is here

Message Edited by TonP on 09-29-2006 06:37 PM

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 3 of 4
(3,637 Views)
Thank you both.  I only put it in a while loop so i could change the values in the array and have it update but in my application i'm not going to do this.

You're right that it makes no sense but I usually like to confuse myself throughly before i submit a post and ask for help.  That vi was a conglomeration of thoughts.
0 Kudos
Message 4 of 4
(3,630 Views)