I have below script and i am able to get the required info. but the string sizes are different in the output. so that i want to print the output in a grid format like as follows. could some one please advice me to print the output in grid format.
ASDF | 67 | ujuhh
QWEDD | 54 | jhj
@echo off
setlocal EnableDelayedExpansion
echo ---------------------------------------------------------------------------
echo Queue ^| type ^|put ^| get ^|Maxdepth^|cudepth^|usage
echo ----------------------------------------------------------------------------
set details=
echo "display ql(*)" | runmqsc QMGR > output.txt
for /F "delims=" %%a in (output.txt) do (
set details=!details!%%a
set property=%%a
if "!property:usage=!" neq "!property!" (
for /F "tokens=1-14 delims=()" %%a in ("!details!") do (
echo %%b^|%%d^|%%f^|%%h^|%%j^|%%l^|%%n
)
set details=
)
)
it should be like a perfect table of contents.
Queue length max 48 chars like type 6 , put 8 maxdepth 7 curdepth 7 usage 7 chars
---------------------------------------------------
Queue -------------------------|type--|put----| get--- |Maxdepth|cudepth|usage
----------------------------------------------------------------------------
system.jdfkjdhfkdj.khkdhfkd------|LOCAL|enabled|enabled|10000----|100----|NORMAL
kjhfksjdfhdkfjhkdsfjds_2323.sdjj---|LOCAL|enabled|disabled|10000----|100----|NORMAL
output data alignment.
Moderator: DosItHelp
Re: output data alignment.
thanks...i got the solution for that topic...
Re: output data alignment.
i am looking to print out in perfect grid format of output for variable length of strings.
Re: output data alignment.
Just use the batch variable string replacement (for example "!line:~-4!" as foxidrive has linked), but now 7 times (Queue, type, ...):
penpen
Code: Select all
:: only the for loop changed, so other code stays
:: (...)
for /F "tokens=1-14 delims=()" %%a in ("!details!") do (
:: leading spaces (as many, as you need per column, so 48 spaces for cQueue, ...)
set "cQueue= %%b"
set "cType= %%d"
set "cPut= %%f"
set "cGet= %%h"
set "cMaxdepth= %%j"
set "cCudepth= %%l"
set "cUsage= %%n"
echo !cQueue:~-48!^|!cType:~-6!^|!cPut:~-8!^|!cGet:~7!^|!cMaxdepth:~-7!^|!cCudepth:~-7!^|!cUsage:~-7!
:: (...)
penpen
Re: output data alignment.
excellent,...:0
Many thanks for the solution.
Many thanks for the solution.
Re: output data alignment.
dont we have a Format function in the library that would work for this?