1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WAD 4DOS and benny.bat

Discussion in 'Support' started by w_krieger, Jan 15, 2014.

  1. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    175
    Likes Received:
    0
    You probably do not know of this ancient DOS bug, and it probably does not matter much nowdays, but all versions of command.com (except freedos), support an interesting bug as given in the following batch. 4DOS, 4OS2 and 4NT do not, but you can always include a different test for it.

    Code:
    @ECHO OFF
    ::  Benny Penderson, "Hex-Hax" of the year of the Lord, 19:0 .
    choice /n /cABCDEFGHIJKLMNOPQRSTUVWXYZ Choose drive:
    :  FINDCD
    FOR %%D IN (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF ERRORLEVEL H%%D SET DRIVE=%%D
    ECHO You chose drive %DRIVE%
    
    FOR %%D IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO IF ERRORLEVEL x%%D SET DRIVE=%%D
    ECHO You chose drive %DRIVE%
    
    Basically, it sets the error code to CHR$(D)-48, and treats the number modulo 100. The above code returns A or a if selected for 1, B or b if 2 is selected.
    Hex Hax is a reminder for the upper and lower case letters, and the 19:0 is 2000 as "19"+CHR$(tens+48)+CHR$(units+48)
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,288
    Likes Received:
    39
    You're reporting a bug in COMMAND.COM?
     
  3. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    175
    Likes Received:
    0
    Yes, but it's a handy thing to know if you have to suffer it on some machine.
     

Share This Page