4.46 how to pass variable to latex to change the compile content?

I use this method which works ok for me. I have a file called switch.tex where the switch is set to true or false. I have to edit this file to change the switch. Then in the main latex document, I input this file. This diagram shows the process.

\ifbool{switch} 
{.... latex code to compile when switch is true....} 
{.... latex code to compile when switch is false....}