Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for usrinput.bat

(view source code of usrinput.bat as plain text)

  1. @ECHO OFF
  2. REM * Ask for USeR INPUT and store it in variable USRINPUT
  3. REM * Assumes ANSI.SYS is loaded
  4. REM * Written by Rob van der Woude
  5.  
  6. SET USRINPUT=
  7.  
  8. REM * Turn on ANSI key translation (translate Enter
  9. REM * key to F6+Enter sequence) and ask for input:
  10. ECHO Enter one word only . . .
  11.  
  12. REM * Copy entered text to temporary file:
  13. COPY CON %TEMP%.\~USRINP.TMP
  14.  
  15. REM * Turn off ANSI key translation and clear irrelevant screen output:
  16. ECHO 
  17.  
  18. REM * Add empty line to temporary file. The empty line
  19. REM * will be used to stop DATE asking for new date.
  20. ECHO.>> %TEMP%.\~USRINP.TMP
  21. ECHO.>> %TEMP%.\~USRINP.TMP
  22.  
  23. REM * Create a temporary batch file that will store the
  24. REM * entered text into the environment variable USRINPUT:
  25. TYPE %TEMP%.\~USRINP.TMP | DATE | FIND "):" > %TEMP%.\~USRINP.BAT
  26.  
  27. REM * Create more temporary batch files. Add
  28. REM * more command line parameters if necessary,
  29. REM * as in: ECHO SET USRINPUT=%%3 %%4 %%5 %%6 %%7 %%8 %%9>CURRENT.BAT
  30. ECHO SET USRINPUT=%%3>CURRENT.BAT
  31.  
  32. REM * VOER.BAT and TYP.BAT are replacements for CURRENT.BAT for Dutch
  33. REM * DOS versions; add your own language versions if necessary:
  34. ECHO SET USRINPUT=%%6>VOER.BAT
  35. ECHO SET USRINPUT=%%4>TYP.BAT
  36.  
  37. REM * This temporary batch file now sets the variable USRINPUT:
  38. CALL %TEMP%.\~USRINP.BAT
  39.  
  40. REM * Display the result:
  41. ECHO You typed: %USRINPUT%
  42. ECHO.
  43. PAUSE
  44.  
  45. REM * Finally, clean up the mess of temporary files:
  46. FOR %%A IN (%TEMP%.\~USRINP.BAT %TEMP%.\~USRINP.TMP VOER.BAT TYP.BAT CURRENT.BAT) DO DEL %%A
  47.  

page last uploaded: 2017-08-21, 14:26