Howdy, I am currently struggling with an array of values that I want to re-arrange in a programmatic way. My program is a mix of ladder and STX, with some tricks to make user input of array values on the HMI a little less of a headache.
To start I have a string that the user can edit, formatted;
I then convert the string to a 2 dim array of sint[20,4], formatted;
For some of the User input, they would need to modify the order of each array. Rather than have them retype the order, I'd like to rearrange it as follows
Reversed order of the 1st dim array values
I was looking at the SWPB (Swap Byte), but not sure if it will accomplish what I need since my bytes are across array elements. Maybe some ladder with some FIFOs, if I can get it to reverse with the empty 0 elements offsetting the reversal of values.
Seems like something simple but curious if someone has a different approach besides STX for loops.
P.S. I'll need to reassemble the reversed string too, to inform the user of the change in order.
To start I have a string that the user can edit, formatted;
Code:
"1,2,3#4,6,5#7,8#9"
I then convert the string to a 2 dim array of sint[20,4], formatted;
Code:
array[0,0] = 1
array[0,1] = 2
array[0,2] = 3
array[1,0] = 4
array[1,1] = 6
array[1,2] = 5
array[2,0] = 7
array[2,1] = 8
array[3,0] = 9
all other array values = 0;
For some of the User input, they would need to modify the order of each array. Rather than have them retype the order, I'd like to rearrange it as follows
Reversed order of the 1st dim array values
Code:
array[0,0] = 3
array[0,1] = 2
array[0,2] = 1
array[1,0] = 5
array[1,1] = 6
array[1,2] = 4
array[2,0] = 8
array[2,1] = 7
array[3,0] = 9
I was looking at the SWPB (Swap Byte), but not sure if it will accomplish what I need since my bytes are across array elements. Maybe some ladder with some FIFOs, if I can get it to reverse with the empty 0 elements offsetting the reversal of values.
Seems like something simple but curious if someone has a different approach besides STX for loops.
P.S. I'll need to reassemble the reversed string too, to inform the user of the change in order.