Hello everybody.
For a project, I need to make a queue that stores REAL's.
There needs to be the possibility to select a place and than move the selected place up or down, removing, etc.
I first made a simple version in FBD, but everything is written out long and it's not dynamic at all. (For example if the length of the queue needs to be bigger)
Queue is an array[1..10], this is how it was done for adding something.
If Queue[10] doesn't has a value and the signal to add value comes on then
move Queue[9] to Queue[10]
move Queue[8] to Queue[9]
move Queue[7] to Queue[8]
move Queue[6] to Queue[7]
move Queue[5] to Queue[6]
move Queue[4] to Queue[5]
move Queue[3] to Queue[4]
move Queue[2] to Queue[3]
move Queue[1] to Queue[2]
move New_value to Queue[1]
Now I should make this again but in STL (Step 7) and dynamic but I'm really struggling with the use of pointers.
I know you can put a variable into a pointer and calculate with it every loop.
As far as I can see, you first need to know how big the queue is minus 1 to aim for the ninth spot, but also needs to have the offset of a REAL (4 bytes) so u can move this value.
I don't see how i can write this out, hopefully someone can clear this out for me so i can get started and do the move up, down, etc. part on my own.
Thanks in advance!
For a project, I need to make a queue that stores REAL's.
There needs to be the possibility to select a place and than move the selected place up or down, removing, etc.
I first made a simple version in FBD, but everything is written out long and it's not dynamic at all. (For example if the length of the queue needs to be bigger)
Queue is an array[1..10], this is how it was done for adding something.
If Queue[10] doesn't has a value and the signal to add value comes on then
move Queue[9] to Queue[10]
move Queue[8] to Queue[9]
move Queue[7] to Queue[8]
move Queue[6] to Queue[7]
move Queue[5] to Queue[6]
move Queue[4] to Queue[5]
move Queue[3] to Queue[4]
move Queue[2] to Queue[3]
move Queue[1] to Queue[2]
move New_value to Queue[1]
Now I should make this again but in STL (Step 7) and dynamic but I'm really struggling with the use of pointers.
I know you can put a variable into a pointer and calculate with it every loop.
As far as I can see, you first need to know how big the queue is minus 1 to aim for the ninth spot, but also needs to have the offset of a REAL (4 bytes) so u can move this value.
I don't see how i can write this out, hopefully someone can clear this out for me so i can get started and do the move up, down, etc. part on my own.
Thanks in advance!
Last edited: