Move data from array to Global Variables

It's outside the scope of the help I need.
But okay, here goes:

In simple words: I have an Ikea remote that switches between my Sonos speakers. When I switch speaker I want a TTS announcement. This TTS announcement is in a condition. Before the TTS i need to store the variable from the array into a global variable. After the TTS I will switch to the queue (with URI). After that I need to set the track according to the trackNumber (which I also want to store in a global variable).