I'm not sure what you are trying to do with BaseSwitchSOL. When you get the the Else clause it will always equal undefined so it will always Catch. This is because each time the script is run, it's a new instance of the script, so BaseSwitchSOL always starts as undefined. You would need to make it global to keep the value…
i'm sry for my complete noobishness, i do not even know if this is intelligent or not, but couldnt you redraw your screen as last statement in your script? so you would refresh the screen, but not actually change its focus