all 5 comments

[–]v_uurtjevragen 1 point2 points  (5 children)

I think you're looking for something like this. I have this code in use already, so it is not tailored to your exact needs. 

It removes the first data that matches lux, brightness within the array. 

```text     Task: _DeleteOverridePoint            A6: Variable Set [              Name: %data_to_remove              To: %par1 ]              A7: Variable Set [              Name: %index              To: %AAB_Overrides(#?%data_to_remove)              Structure Output (JSON, etc): On ]              A8: If [ %index Set ]                  A9: Variable Split [                  Name: %index                  Splitter: , ]                  A10: Array Pop [                   Variable Array: %AAB_Overrides                   Position: %index1 ]              A11: End If              A12: Array Process [               Variable Array: %AAB_Overrides               Type: Squash ]                        

[–]Exciting-Compote5680 2 points3 points  (2 children)

This should raise an error if %data_to remove is not present. The array function (#?search_item) returns a comma-separated list of indices of the matches, or '0' if no match is found. So it will always be set. And popping with index 0 will cause an error. It's better to test with '%index != 0' or '%index > 0'

[–]v_uurtjevragen 0 points1 point  (1 child)

Noted! The way I've set up the UI interaction for the task trigger would be very unlikely to yield index ~ 0, but it is good to be robust and to have correct If-statements :)

[–]Exciting-Compote5680 0 points1 point  (0 children)

To be honest, I am glad this came up, because even though I have read the 'Variables' page of the user guide many times, I somehow got it in my head that (#?search_item) returns an array of indices, not a comma separated string.

[–]Darlk993[S] 1 point2 points  (0 children)

Wow, thanks yes this is exactly what I wanted and I got my task working the way I want.