0

Another question about batch files

i know how choice works (also choice.com) but once in the back ive seen an option menu that would let you to toggle between options

like something [ON] OFF and when toggled something ON [OFF] vice versa

i know 2 ways ..

which 1 way is to write both conditions and display the one needed ..
and the other is to toggle "[  ]" signs ...

i cant do the 2nd way and need some help.. also ive been looking at movement articles but they do not seem to have anything to help

thx for reading the passage and have a nice day :)

xDeathwing
  • 139
  • 13

1 Answers1

0

There are probably dozens of ways to accomplish this. Here is one simple way, likely not the most elegant but it works:

@echo off

set _on=0

:top
cls

if %_on%==0 (set _nlb= &set _nrb= &set _flb=[&set _frb=]) else (set _nlb=[&set _nrb=]&set _flb= &set _frb= )

echo The '_on' flag is currently: %_nlb% On %_nrb%  %_flb% Off %_frb%
echo.
echo Press any key to toggle the '_on' flag
pause>nul

if %_on%==0 (set _on=1) else (set _on=0)
goto top
James L.
  • 9,384
  • 5
  • 38
  • 77