Dynamic Switch list using OSC listener

Hi All. I've found some great answers already on this forum, but am stuck on this one...
The below code works well to populate switch values from incoming OSC.

JS{{
	var values = {}
	values[OSC{/SongName0,Song 1}] = 0 
	values[OSC{/SongName1,Song 2}] = 1
	values[OSC{/SongName2,Song 3}] = 2
	values[OSC{/SongName3,Song 4}] = 3
	values[OSC{/SongName4,Song 5}] = 4
	return values
}}

But I would like this list to be dynamic - based on a song_count variable.

This is the closest I have got:

JS{{
	var values = {}
	var i, idx;
	for (i = 0; i < @{song_count}; i++) { 
		idx = "\O\S\C{/SongName"+i+",Song"+i+"}";
		values[idx] = i
	};
	return values
}}

But I can't get the OSC listener command to be treated correctly, as the switch value just shows the text:

image

This can't be recognized by the parser, you can't write an OSC{} block dynamically ln a JS{} block (OSC{} blocks are evaluated before JS{} blocks anyway).

Ah, ok, thanks for confirming. I thought I'd seen some dynamic use of the OSC block for matrix labels mentioned in another topic, so hoped it would work. I will define the list manually, as that was working well.