List of Lists - Create, Update, Extract

List of Lists problem

It is day 3 for me and I am making progress but have looked at a number of posts about lists of lists but can’t see exactly how the examples work and how I would store and retrieve and update the data.

I am wanting to store a series of four pairs of X,Y coordinates from three sensors. Basically, an array “Sensor_List[3][4][2]” The data being supplied by a Bluetooth connection so no typing into text boxes or presenting in text boxes.

I have the Bluetooth bit working fine as I am already plotting results on the canvas. As far as I can tell the initialisation of ‘Sensor_List’ is correct as it looks like this.

[[[0,0],[0,0],[0,0],[0,0]],[[ 0,0],[0,0],[0,0],[0,0]],[[ 0,0],[0,0],[0,0],[0,0]],[[ 0,0],[0,0],[0,0],[0,0]]]

However, I keep getting errors

Runtime Error

The operation add items to list cannot accept the arguments: , [0], [0], [0]
Note: You will not see another error reported for 5 seconds

You will see that I have debug label text just before the add items to the list to check that I am not trying to use zero values as list indexes

You will also see that ‘Store_Plot’ has write/read function controlled by “Insert” flag. The code in the ‘else’ is there hoping that the ‘write’ worked and I could test to see if I could get data out. It is disabled for now just in case it contributed to the problem.

My questions please

  • What is the problem with the failed write to the list?
  • What would be the smart way to extract the X,Y pairs.?

No sooner than I posted this I discovered 'Do It' and found the problem. I had to many "select list item" steps.

That sorted it ran but kept appending new list items, which eventually crashed my tablet. That led me to "replace list item" which still didn't work because I had the indexing the wrong way round, it works outwards not inwards

So now it is fixed

Having got this far I'll probably quickly find out how to get the data out. I'll leave open and post how I've done that. Then close the thread

Now having found how to defined the array (list) and index to an item to update it, getting the data out again is similar

1 Like