Description: |
call:Format fmt str1 str2 ... |
Script: |
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19.
|
:Format fmt str1 str2 ... -- outputs columns of strings right or left aligned
:: -- fmt [in] - format string specifying column width and alignment, i.e. "[-10][10][10]"
:$created 20060101 :$changed 20091130 :$categories Echo
:$source https://www.dostips.com
SETLOCAL
set "fmt=%~1"
set "line="
set "spac= "
set "i=1"
for /f "tokens=1,2 delims=[" %%a in ('"echo..%fmt:]=&echo..%"') do (
set /a i+=1
call call set "subst=%%%%~%%i%%%spac%%%%%~%%i%%"
if %%b0 GEQ 0 (call set "subst=%%subst:~0,%%b%%"
) ELSE (call set "subst=%%subst:~%%b%%")
call set "const=%%a"
call set "line=%%line%%%%const:~1%%%%subst%%"
)
echo.%line%
EXIT /b
|
|