After doing a lot of research on dostips about macros, and a fast color code (thank you einstein1969) I wanted to create a color macro. CALL execution is slow, but macros are fast!
Is it possible to make this faster? I'm out of ideas..
Only tested on Win10 64bit
Code: Select all
@echo off & setlocal enableDelayedExpansion
rem Code for color support
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E & echo on & for %%b in (1) do rem"') do set "DEL=%%a"
<nul set /p ".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%" > "'"
rem Code for macro support
set ^"LF=^
^" Above empty line is required - do not remove
set ^"\n=^^^%LF%%LF%^%LF%%LF%^^"
rem macros - %getArgs% ""TEXT".95 "TEXT".BE "TEXT".C1 "TEXT".5D"
rem - %colorArgs%
set getArgs=for %%# in (1 2) do if %%#==2 ( set "arguments=0" ^& for %%a in ("^!args^!") do (%\n%
set /a "arguments+=1" ^& for /f "tokens=1,2 delims=." %%0 in ("%%~a") do if "%%1" neq "" (%\n%
set "T[^!arguments^!]=%%~0"%\n%
set "c[^!arguments^!]=%%~1"%\n%
for /f "tokens=*" %%2 in ("T[^!arguments^!]") do set "%%~2=^!%%~2:~0,-1^!"%\n%
))%\n%
for /f "tokens=*" %%2 in ("c[^!arguments^!]") do set "%%~2=^!%%~2:~0,-1^!"%\n%
set "T[1]=^!T[1]:~3^!"%\n%
) else set args=
set "colorArgs=(for /l %%a in (1,1,^!arguments^!) do ( echo=^!t[%%a]^!\..\')^>cp.txt ^&^& findstr /a:^!c[%%a]^! /f:cp.txt ".") & echo."
echo.
%getArgs% ""Macro test".5A " 1 ".4E " Unlimited parameters".9B"
%colorArgs%
echo.
%getArgs% ""Macro test".DC " 2 ".2D"
%colorArgs%
echo.
%getArgs% ""Macro test".32 " 3 ".47"
%colorArgs%
echo.
%getArgs% ""Macro test".91 " 4 ".F6"
%colorArgs%
pause & exit