How CHOICE.BAT Works

CHOICE.BAT works by picking up the "%" code from FILER.INI, converting it to %1, inside the CHOICE.BAT program and storing it as an environment variable, Fn (short for Filename). Since there's no second command line parameter, at this time, the CHOICE.BAT program displays the prompt.

When you enter the additional command line parameter, namely E, V or R, the CHOICE.BAT program builds a batch file named $.BAT file and runs it. The $.BAT program contains the line "C:\choice.bat C:\test.bat V" which causes the Choice program to jump to the label :V, invokes the file viewer and loads the TEST.BAT program into it.

The toughest part of understanding this code is keeping the batch file parameters straight. %0 stands for the name of the currently running batch file. %1 stands for the first command line parameter. %2 stands for the second. %Fn% stands for the contents of the environment variable "Fn". If you can keep track of the variables as they go from FILER.INI to CHOICE.BAT to $.BAT and back to CHOICE.BAT, then seriously consider a career in computer programming.