Remotely turn off Self Switch A for ALL events on another map

Hello. I have a map with 170 events, and I'd like to turn off the Self Switch A for all of them before teleporting to the map. I know I can use:

Code:
$gameSelfSwitches.setValue([35, 1, 'A'], false);
$gameSelfSwitches.setValue([35, 2, 'A'], false);
$gameSelfSwitches.setValue([35, 3, 'A'], false);
...etc. until
$gameSelfSwitches.setValue([35, 170, 'A'], false);

but that seems insane to me. Is there an simpler way to just turn them all off for the entire map at once?

Thanks!
You could use a loop, I imagine something like this would work.

Code:
for (i = 1, l = $gameVariables.value(1), m = $gameVariables.value(2); i < l;) {
$gameSelfSwitches.setValue([[m], [i], 'A'], false);
i++;
};
set l to variables for amount of events, m to map, or just erase it and put in number if only 1
@glaphen

That works beautifully, thanks so much!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/remotely-turn-off-self-switch-a-for-all-events-on-another-map.118050/