Interacting with all arrays

Hey there!
I currently have an array in my code, but I have absolutely no idea on how to interact with all of them at the same time. (I only know how to interact with specific ones)
That’s my current array:

@editable SongArray : []radio_device = array{}

How can I interact with all of them at the same time to stop the radio devices with .Stop()?

Greetings!

Not used the radio_device personally but if it has a Stop method available on it, you could do this:

for (Song: SongArray) {
  Song.Stop()
}

That basically just loops through each Song in the SongArray and calls the Stop method on the radio_device (Song) as it iterates through them.

Or alternatively you could write a method in your creative device class like this:

StopRadioDevices(RadioDevices: []radio_device): void = {
  for (RadioDevice: RadioDevices) {
    RadioDevice.Stop()
  }
}

This allows you to pass any number of radio_devices to the StopRadioDevices method, where it then does the same as the first snippet, just in a more reusable format. And then you can pass in your SongArray like so:

StopRadioDevices(SongArray)

I haven’t tested this so it may need adjusting, and there could also be a global way to stop all devices that I’m unaware of, but that should do the trick. It could also get a bit hectic depending on how many radio_devices you’re using as it iterates through the array, so keep that in mind too.