I have a settings.txt file that looks like this:
on
off
In the beginning of the batch file, various variable values are populated with these settings such as %AutoTransfer%
being set to on, AutoViewLog
set to on, etc. Whenever one of these settings are toggled on/off, I call the :WriteSettings
function which tries to do this:
echo %AutoTransfer% > settings.txt
echo %AutoViewLog% >> settings.txt
But instead the command interpreter turns echo itself on or off. I've tried !AutoTransfer!
and (!AutoTransfer!)
still with no luck. Of course I can change it to using enabled/disabled values instead of on/off values but that screws up my menu that relies on these words being short. And if I resort to setting the values to be 1 for enabled and 0 for disabled, I have to write tons more code for the main menu (a bunch of "if" statements to echo "on" when the variable is 1, "off" when it is 0).
My current solution would work... it would assign values to "is on" instead of "on" and just make the word "is" part of the value of the variable so that I can use 'AutoTransfer %AutoTransfer%'
on the menu to display "AutoTransfer is on"
. But this feels like a duct tape solution, and for the pure virtue of learning, I want to know if there is an elegant solution to this or if all solutions are just as stupid/lame/ugly as that or possibly worse.
I also can't believe I seem to be the first to ask this question. I looked for 20 minutes for anyone else who has asked this question... couldn't find a single one. Am I really the first person who ever wanted to store/read/echo super basic "on/off" values to a settings file and to the screen? Or am I just the first person who is too dumb to figure it out?