LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string array to boolean array

Solved!
Go to solution

I'm trying to split this array into 4 other arrays and I'm having trouble with conversions. I have 5 columns of Booleans and 3 of Hex /String values.

0 Kudos
Message 1 of 7
(4,754 Views)

It would help if you supplied some typical data.  But at the top of my head, use a FOR loop to process each row (auto-index the input array).  Inside of the FOR loop, use Index Array and Array Subset to get your individual columns and parse them however you need to. 


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 2 of 7
(4,750 Views)

Which is "this array"?  Is it the Load Setup string array?

 

What does the data in it look like?  Without knowing the format of that data, it's impossible to help you convert it to booleans or other datatypes.

 

Shouldn't you have a loop around your event structure?

Why the unused local variables?

0 Kudos
Message 3 of 7
(4,747 Views)

Most the information you guys are asking for is there. I forgot to set the data as default so I'm reloading it.

 

Enable Relay, Measurement Trigger and The PWM1-4 are arrays of Boolean. The SPI commands are hex values. I'm using local variables because that's what I'm using in the larger VI. This is just a snippet.

0 Kudos
Message 4 of 7
(4,712 Views)

I was trying to avoid looping if I could but I'll give it a try and let you know how it goes.

0 Kudos
Message 5 of 7
(4,710 Views)

@RHutchings wrote:

Most the information you guys are asking for is there.


While that may be true, it's not there in a way that makes quick sense to someone that's trying to help you.  You've got a lot on the FP and no real explanation of what's taking place.  When someone is looking to help you for free, they're generally not going to invest a large amount of time trying to understand something you can quickly explain.

 

Without a VI that runs, it's also a bit harder to go through things and make tweaks.  You'll generally get better help providing a running VI.

 

That said, why would you want to avoid loops?  It looks like you want to take in the string and convert the hexadecimal values into either numerics or boolean.  Your code shows numerics.  You're asking for booleans.  Hit ctrl+space on the block diagram and type in "boolean array"  You'll find a pair of operations that convert boolean arrays and numbers back and forth.  This would be the easiest way I can imagine to do the task.  Even with that, you'll have a bit of work to go through those arrays unless you use loops.

0 Kudos
Message 6 of 7
(4,705 Views)
Solution
Accepted by topic author RHutchings

Pretty simple.  See attached.

 

Issues I saw.

1.  It seemed like all your indicators should be controls and all your controls should be indicators.  Like you have inputs and outputs mixed up.  That is why you were stuck using local variables for everything.

2.  You used an event structure, which generally means something to happen repeatedly whenever an event happens.  Without a loop around it, you've got a 1-run VI.  I just removed the event structure.  That event would have never run anyway because Read Setup was a value change event, but the boolean was an indicator.  So no user interaction would have triggered the event.

 

W


@RHutchings wrote:

I was trying to avoid looping if I could but I'll give it a try and let you know how it goes.


What is wrong with looping that you need to avoid it?  PC's are excellent at looping and repeatedly doing things over and over!.  However, in this case, the actual conversion does not require loops because the conversion and comparison primitives will act on arrays.

 

Download All
Message 7 of 7
(4,700 Views)