Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for asc.bat

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

  1. @GOTO :Batch
  2.  
  3. A 100
  4. MOV AH,08
  5. INT 21
  6. CMP AL,0
  7. JNZ 010A
  8. INT 21
  9. MOV AH,4C
  10. INT 21
  11.  
  12. RCX
  13. E
  14. N ASC.COM
  15. W
  16. Q
  17.  
  18. :Batch
  19. @ECHO OFF
  20. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  21. IF "%~1"=="" GOTO Syntax
  22.  
  23. PUSHD "%Temp%"
  24. DEBUG < "%~f0" >NUL
  25. POPD
  26.  
  27. SET Chr=%~1
  28. ECHO.%Chr%| "%Temp%.\ASC.COM"
  29. SET Asc=%ErrorLevel%
  30. DEL "%Temp%.\ASC.COM"
  31. SET Chr
  32. SET Asc
  33. EXIT /B %Asc%
  34.  
  35.  
  36. :Syntax
  37. ECHO.
  38. ECHO Asc.bat,  Version 1.00 for Windows NT 4 / 2000 / XP
  39. ECHO Return the ASCII number for the specified character, more or less
  40. ECHO like many scripting languages' Asc( ) functions
  41. ECHO.
  42. ECHO Usage:  ASC.BAT  char
  43. ECHO.
  44. ECHO    or:  ASC.BAT  "char"
  45. ECHO.
  46. ECHO Where:  "char"   is the character whose ASCII value you want to know
  47. ECHO                  (space or "interpreted" characters in doublequotes)
  48. ECHO.
  49. ECHO Notes:  This batch file cannot handle a single doublequote character
  50. ECHO         (ASCII value 34) nor a carriage return (13), linefeed (10),
  51. ECHO         ampersand (38), less than (60), greater than (62) or pipe (124).
  52. ECHO         The result is displayed on screen and returned as "errorlevel".
  53. ECHO         This batch file uses DEBUG to create a temporary utility ASC.COM.
  54. ECHO.
  55. ECHO Written by Rob van der Woude
  56. ECHO http://www.robvanderwoude.com
  57.  

page last modified: 2024-04-16; loaded in 0.0196 seconds