One of my early posts on dostips is A:CHR routine that could convert a number into the corresponding character. The final code that appears near the "End of" the thread works really, and are fast, but nearly all the characters must Be embedded in the script. The TAB character in particular can is problematic, especially when trying to post the "Code on a forum site."
There is the undocumented%=exitcodeascii% dynamic variable This converts the most error code (from Exit, not exit /b), but it is limited to codes between and 126.
I had never seen a native method to generate a TAB character this works on all Windows Versions-until now
I recently ran across this forfiles documentation gem at ss64.com:
Copy Code code as follows:
To include special characters into the command line with the hex code for the character in 0xHH format (ex. 0x09 is Thetab c Haracter, 0x22 is the double quote "character.)
Eureeka:idea:-The following simple Printhex routine can generate any byte code value except 0x00 (nul), 0x0A (newline), and 0x0D (carriage return). 8)
@echo off
setlocal
::D efine A linefeed variable
set lf=^
:: Above 2 blank lines are critical-do not Remov E.
:: Create a tab variable
call:hexprint "0x09" tab
::P rint A string with encoded TABs call:hexprint
"A0 X09b0x09c "
:: Create A string variable with encoded TABs
call:hexprint" a0x09b0x09c "var
set var
exit
/b: Hexprint string [Rtnvar]
for/f eol^=^%lf%%lf%^ delims^=%%a in (
' forfiles/p '%~dp0. "/M"%~nx0 "/C" cmd/c Echo (%~1 ""
) do If "%~2" Neq "" (set%~2=%%a) Else Echo (%%a
exit/b
I ' ll be playing Native American style flutes at a retreat in the Blue Ridge Mountains of Virginia for the next 4 days:D, Without computer access: |
I wanted to post this before I left.
Enjoy the code, while I Enjoy the crisp fall air. :)
Dave Benham