@rem quiz.bat
@rem RJM Programming
@rem May, 2016
@echo To sleep,
@ping -n 2 127.0.0.1 >nul
@echo perchance,
@ping -n 2 127.0.0.1 >nul
@echo to dream.
@ping -n 2 127.0.0.1 >nul
@set score=0
@set goes=0
@echo.
@echo Okay, got the gist ... try this quiz with 2 seconds between answering each question ...
@echo.
@echo Ready?
@echo.
@ping -n 2 127.0.0.1 >nul
@echo off
 CHOICE <nul >nul 2>nul
 IF %errorlevel% equ 255 goto x64
:tryarch
 if %PROCESSOR_ARCHITECTURE%trick==x86trick goto x32
:x64 
 CHOICE /N /D:0 /T:10 /C:1234567890 /M "Question 1 of 10: How many Queens in one deck of cards?"
 IF %errorlevel% equ 4 set /a score=%score% + 1
 if %errorlevel% neq 4 echo No, that should be 4.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:0 /T:10 /C:1234567890 /M "Question 2 of 10: How many moons does Mars have?"
 IF %errorlevel% equ 2 set /a score=%score% + 1
 if %errorlevel% neq 2 echo No, that should be 2.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:Z /T:10 /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ /M "Question 3 of 10: What musical note do orchestras tune to?"
 IF %errorlevel% equ 1 set /a score=%score% + 1
 if %errorlevel% neq 1 echo No, that should be A.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:0 /T:10 /C:1234567890 /M "Question 4 of 10: How many sides does a septagon have?"
 IF %errorlevel% equ 7 set /a score=%score% + 1
 if %errorlevel% neq 7 echo No, that should be 7.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:Z /T:10 /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ /M "Question 5 of 10: Which Roman numeral equals 50?"
 IF %errorlevel% equ 12 set /a score=%score% + 1
 if %errorlevel% neq 12 echo No, that should be L.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:Z /T:10 /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ /M "Question 6 of 10: Which letter is worth 5 in Scrabble?"
 IF %errorlevel% equ 11 set /a score=%score% + 1
 if %errorlevel% neq 11 echo No, that should be K.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:Z /T:10 /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ /M "Question 7 of 10: Which is the most commonly used letter in Polish?"
 IF %errorlevel% equ 9 set /a score=%score% + 1
 if %errorlevel% neq 9 echo No, that should be I.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:0 /T:10 /C:1234567890 /M "Question 8 of 10: Which square number is the largest smaller than 10?"
 IF %errorlevel% equ 9 set /a score=%score% + 1
 if %errorlevel% neq 9 echo No, that should be 9.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:Z /T:10 /C:ABCDEFGHIJKLMNOPQRSTUVWXYZ /M "Question 9 of 10: What is chemical symbol for Potassium?"
 IF %errorlevel% equ 11 set /a score=%score% + 1
 if %errorlevel% neq 11 echo No, that should be K.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 CHOICE /N /D:0 /T:10 /C:1234567890 /M "Question 10 of 10: Which Fibonacci number is the largest smaller than 10?"
 IF %errorlevel% equ 8 set /a score=%score% + 1
 if %errorlevel% neq 8 echo No, that should be 8.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 12 127.0.0.1 >nul
exit /b
:x32
 set /p ans=Question 1 of 10: How many Queens in one deck of cards? < nul
 call :getkey
 if %errorlevel% equ 52 set /a score=%score% + 1
 if %errorlevel% neq 52 echo No, that should be 4.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 2 of 10: How many moons does Mars have? < nul
 call :getkey
 if %errorlevel% equ 50 set /a score=%score% + 1
 if %errorlevel% neq 50 echo No, that should be 2.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 3 of 10: What musical note do orchestras tune to? < nul
 call :getkey
 if %errorlevel% equ 97 set /a score=%score% + 1
 if %errorlevel% neq 97 echo No, that should be A.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 4 of 10: How many sides does a septagon have? < nul
 call :getkey
 if %errorlevel% equ 55 set /a score=%score% + 1
 if %errorlevel% neq 55 echo No, that should be 7.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 5 of 10: Which Roman numeral equals 50? < nul
 call :getkey
 if %errorlevel% equ 108 set /a score=%score% + 1
 if %errorlevel% neq 108 echo No, that should be L.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 6 of 10: Which letter is worth 5 in Scrabble? < nul
 call :getkey
 if %errorlevel% equ 107 set /a score=%score% + 1
 if %errorlevel% neq 107 echo No, that should be K.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 7 of 10: Which is the most commonly used letter in Polish? < nul
 call :getkey
 if %errorlevel% equ 105 set /a score=%score% + 1
 if %errorlevel% neq 105 echo No, that should be I.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 8 of 10: Which square number is the largest smaller than 10? < nul
 call :getkey
 if %errorlevel% equ 57 set /a score=%score% + 1
 if %errorlevel% neq 57 echo No, that should be 9.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 9 of 10: What is chemical symbol for Potassium? < nul
 call :getkey
 if %errorlevel% equ 107 set /a score=%score% + 1
 if %errorlevel% neq 107 echo No, that should be K.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 2 127.0.0.1 >nul
 set /p ans=Question 10 of 10: Which Fibonacci number is the largest smaller than 10? < nul
 call :getkey
 if %errorlevel% equ 56 set /a score=%score% + 1
 if %errorlevel% neq 56 echo No, that should be 8.
 set /a goes=%goes% + 1
 echo.
 echo Score %score% from %goes% goes
 echo.
 ping -n 12 127.0.0.1 >nul
exit /b

@rem Below, thanks to https://www.google.com.au/search?q=detecting+key+pressed+by+if+errorlevel&ie=utf-8&oe=utf-8&gws_rd=cr&ei=27Q7V7CoCoiq0QSq2Zz4DQ#q=detecting+key+pressed+in+dos

   @rem ========================================
   @rem GETKEY.BAT - Written by Paul Tomasi 2010
   @rem
   @rem Waits for keypress. Returns key value
   @rem ========================================
   ::---------------------------
   :: GETKEY
   ::---------------------------
   :getkey
      (
         echo a
         echo mov ah, 08
         echo int 21
         echo mov ah, 4c
         echo int 21
         echo.
         echo rcx
         echo 08
         echo n getkey.com
         echo w
         echo q
      )>script
      debug<script>nul
      call getkey.com
   goto :eof


