09-17-2020 02:00 PM
I am trying to scroll the output of a 2D array. I have it working but it is displayed as two scrolling string indicators. It would be nice to have the display in the form of a table. I have tried to modify what I have to output to a scrolling table but I cannot seem to get it. any suggestions would be nice, thank you
09-17-2020 03:35 PM
Why don't you just combine those two 1-D arrays into a 2-D array.
A table is a 2-D array of strings.
Other odd constructs.
1. Using a Value Property Nodes when you could just build the strings with a shift register.
2. Using a While Loop for a known number of iterations when you really should be using a For Loop.
3. Using Index Array in the While Loop with the i terminal when you could just auto-index the arrays at the For Loop tunnels.
09-17-2020 07:11 PM
ravens already said, there is so much wrong with your code.
A few more comments:
Here are a few ideas.
09-18-2020 07:57 AM
thanks for the tips after posting I did start going in the directions of just inputting the two arrays into table as a 2D array..
Yeah, using the for loop makes more sense.
Yes, both inputs are the same size. what I was trying to do with the property nodes is to push the data up as a new row is inserted into the table. Not sure if this is the best method but I got it to work using a Table"indexVals" property node.
Thanks for the help.
09-18-2020 08:11 AM
That looks MUCH better.
09-18-2020 12:18 PM - edited 09-18-2020 12:22 PM
You still have some serious flaws, for example the U32 subtraction will result in a gigantic number for the first few iterations. Also you really should make it scalable. There is a property node to detect how many rows are showing in the table indicator.
Try this instead:
Note that you need to do the subtraction as signed integers to prevent rollover. You know the sized based on [i] so there is no need to measure the array size with every iteration.
Also note that it is safer to build the 2D array before the loop. Now the shorter array will get padded and the longer array will determine the number of iterations. If you autoindex on both arrays, the shorter will win. (no issue here since you say that the array have the same size, but it is always better to code more flexible and forgiving)
If the sizes are not gigantic, another option would be to insert each new row on top (simply swapping the inputs to "built array"). Now the scroll position can remain at zero and you always see the latest N rows. (This is slightly less memory efficient, but does not matter here).
09-18-2020 12:49 PM
Also, since you don't show the table scrollbar or index display, you really only need to keep the last few entries in the shift register, keeping the array from growing without bounds. Here's how that could look like.