I should state that SwitchFlag must be initialized to a non-zero value at the top of the program.