02-28-2017 01:15 PM
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.
Solved! Go to Solution.
02-28-2017 01:21 PM - edited 02-28-2017 01:22 PM
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.
02-28-2017 01:22 PM
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?
02-28-2017 03:02 PM
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.
02-28-2017 03:10 PM
I was trying to avoid looping if I could but I'll give it a try and let you know how it goes.
02-28-2017 03:16 PM
@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.
02-28-2017 03:25 PM - edited 02-28-2017 03:26 PM
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.