A few alternatives:
- (quick and dirty) since you know that panel x in your CLV corresponds to a specific gauge, in the MQTT message specify the x values too
- use panel tag on each gauge to identify it and parse the CLV when a MQTT message arrives (sporting that specific ID)
- mantain a list (or similar collection) which registers gauge IDs and their position in the CLV
These are just the first three that came to my mind.
Ok, not sure how to do it on the B4A site. Setting a tag is possible but how can I retrieve the item and set it? Sample code? I guess using panel tag is the best way. I might need to change more items inside the panel and list.
Absolutely. Your key is what I called Gauge ID.
If you have a few gauges, option 2 is ok. If they are a lot or if you update very frequently the gauges' data, consider option 3; it's just a trick to reach quickly the desidered item.
A tag is an object, so it can be everything you need. In your case it will probabily be a string representing the Gauge ID.
When an MQTT message arrives, containing a valid ID, you loop on the CLV items to find the one having that string as its Tag.
That's why I suggested the "trick". Looping can take time. Even a short 10 gauges list, if you have to update gauge #9 it implies that you traverse the CLV from start to that position in order to find the corresponding ID.
Using a map, a list or any other collection (even an array of longs) to maintain the position of any specific ID in respect to the CLV item index, let you discover very quickly the item you hace to update. You construct the list in parallel with adding panels to the CLV.
This begins to be useful if you have a lot of gauges or if you have to update them very frequently.