5/21/2016 - part 2 of batch file, documentation panel 1 of 9, last example: change "/g2:2" to "/g2:2:b3" and change "/c8a:176" to "/c176"
- when /c code is used with an ascii code, and a color code is the 3rd delimited value in the /g code, this produces
a border around the grid filled with the ascii character and is colored according to the color codes entered: /g2:2:b3 /c176
5/20/2016 - copy part 1, part2 and samples.bat
-added printable ascii characters in the code range 1-31
-added options to omit one or both border horizontals
-revised gridMaker function to neatly format output batch file and eliminate non-essential
characters fed to ColorShow.exe. example. leading space removed from " /" This fits more
characters into variable for ColorShow so larger grids can be displayed.
-documentation revised to reflect added features
5/10/2016 - end of day - replace just the gridMaker function:
removed 2 lines of test code
supress writing "/07 32*0" to batch file when grid of frames is not being indented
5/10/2016 - bdrCharValidate function--add missing ending quote to 1st 'Set' statement
5/9/2016 - both part 1 & part 2 and samples.bat must be copied to see current samples. various revisions and added functionality:
- add optional outer #2 border to frame (/E code)
- add distinctive column on left or right-side of text area--possible to get the illusion of depth. Previously this was only both right & left columns.
(see documentation, pg. 5, the /b code, and you can see this by entering 'samples 19' and then view #20 also)
- add rem line in saved batch files showing what parameters were used in making the frame or grid of frames.
5/4/2016 - end of day final fix. Refer to top of batch file for revisions.
Updated 5/4/2016 - issues fixed. Re-copy (sorry for that!) just part 1 of the batch code. (edit. copy both
parts if you are not in sync with all these annoying revisions)
Revised 5/4/2016 - error in :writeBatch function, change variable name 'newFileName' to 'saveBAT'
Found issue with doubled % character when text displayed inside the tool. Will resolve.
Revised again on 5/3/2016 - only part 1 of batch code...refer to top of batch file for details.
Updated 5/3/2016 -- ??final features?? added and some tweaking. Re-copy all the code and samples.bat.
To view the added grid sample, enter 'samples 25'.
Updated 4/30/2016 - too many revisions to list. Run FrameTool ? and samples.bat for details
and a look at some frames and new features. The code characters have exceeded the limit of this message.
The bottom code lines for FrameTool.bat are in a post below this, and samples.bat too.
Notice: 04/18/2016 - the tool is being revised in part because of a failure scenario in the
created batch file. Text lines that include " plus other special characters, assigned to the array,
cause an error. There is no error when the frame is displayed from inside the tool, and this will be
the default behavior of the tool. The /F code (creates a new batch file) will still be there.
In the new code, options to colorize lines based on text targets will be increased to up to 5 targets.
I plan to add two more border styles: split line and thick line. Current border styles are
thin line and wide. (edit: thick line border addition not needed...it is the same border as thin-line border with a solid color)
It will probably be about two weeks before the new code is ready to replace the old code.
edit 04/05/2016 - separate the two batch files in this post: frametool.bat from samples.bat
revision: 04/10/2016 - expand tasks for /o code, revise documentation for this, added example to samples.bat
refer to top of file for tool revisions (latest: 4/11/2016)
FrameTool.bat is a batch-vbscript hybrid frame maker that prepares the input for
Aacini’s ColorShow.exe program. Type ‘frametool ?’ to view documentation.
Credits to Aacini and Foxidrive for methods used in this tool.
As a brief summary, vbScript is used in the beginning to handle command line entries
and communicate back to batch which of the tool options was requested (errorlevel),
what the parameters are, in a temporary file named _params_.txt, and what the source
of the text for display is, in a temporary file _source_.txt.
The batch file then handles this information and performs one of the 8 options of the tool.
revised: If a custom frame is being made, by default it is displayed by a function in the tool.
If a new batch filename is entered, the batch file is written and called to display the frame.
At the bottom of this post is samples.bat to show a few examples of bordered frames.
Please comment if you are using as directed and encounter a glitch.
Code corrections may be needed, and code reduction or improvements to code or documentation,
so I am willing to edit the copy in this first post to make the adjustments.
The tool was tested on Windows 7 and XP PCs. Thanks for your feedback.
Jerry
Note: I made no effort to deal with filenames that include spaces. Be safe and leave spaces
out of your filenames.
FrameTool.bat (part 1 of 2):
Code: Select all
<!-- : Begin batch script
@Echo Off
rem Frametool.bat
rem last update: 5/20/2016
If not EXIST ColorShow.exe Echo The file colorshow.exe was not found in this folder. Exiting.& GoTo:eof
If "%1"=="" (
Echo No args given, for example: /b /a4e /i3 {A Message}
ColorShow /07 "Enter " /0a "%0 ? " /07 "to see details." 13 10
GoTo:eof
)
setlocal
:: _____choose your colors for tool documentation panels here_____
Set "infoFrmColors=70"
Set "infoBdrColors=18"
:: _____________________________________________________________________
Set "str=%*"
If EXIST _params_.txt DEL _params_.txt
If EXIST _source_.txt DEL _source_.txt
CScript //nologo "%~f0?.wsf" "%str:"=d_~_q%"
If EXIST _info_.txt (
Set "actionCode=1"
) Else (
Set "actionCode=%errorlevel%"
)
If %actionCode%==0 (
Echo Option, text or existing text filename not given.
ColorShow /07 "For instructions on how to use this tool, enter " /0e "%~n0 ? " 13 10
GoTo:eof
)
setlocal EnableDelayedExpansion
If %actionCode%==6 Call :infoReq "COL" & GoTo:eof
If %actionCode%==7 Call :infoReq "ASC" & GoTo:eof
If EXIST _params_.txt Set /P params=<_params_.txt
If %actionCode%==8 (
If "!params!"=="" Set "params=?"
Call :infoReq "!params!" & GoTo:cleanUp
)
If %actionCode%==9 Call :infoToFile & GoTo:eof
endlocal & set "str=%params%"
If %actionCode% leq 3 If not EXIST _source_.txt (
Echo The VBScript task was not completed.
Echo The temporary file _source_.txt was not found. Exiting.
GoTo:eof
)
Call :paramsValidate "%str%" params gridSpecs eBorder topHZOut botHZOut skipRun
For /F "tokens=1-26 delims=~" %%a In ("%params%") Do (
Set "side=%%a"
Set "border=%%b"
Set "textColors=%%c" & Set "bdrColors=%%d"
Set "indent=%%e"
Set "superWidth=%%f" & Set "superHeight=%%g"
Set "linesAbove=%%h" & Set "linesBelow=%%i"
Set "asciiCode=%%j" & Set "asciiCode2=%%k" & Set "isReverse=%%l"
Set "fillCode=%%m"
Set "marginLeft=%%n"
Set "LineColors1=%%o" & Set "target1=%%p"
Set "LineColors2=%%q" & Set "target2=%%r"
Set "LineColors3=%%s" & Set "target3=%%t"
Set "LineColors4=%%u" & Set "target4=%%v"
Set "LineColors5=%%w" & Set "target5=%%x"
Set "pauser=%%y"
Set "saveBAT=%%z"
)
If not "%saveBAT%"=="0" Call :bNameValidate "%saveBAT%" saveBat
If "%saveBAT%"=="_RESERVED$_" GoTo:cleanUp
If "%actionCode%"=="5" (
Call Set "gridSpecs=%saveBAT%:%%border%%:%%gridSpecs%%"
Call :gridMaker "!gridSpecs!" "%textColors%" "%bdrColors%" "%fillCode%" "%indent%" "%superWidth%" "%superHeight%" "%pauser%" "%skipRun%"
GoTo:cleanUp
)
Set /A "widthLimit=150" & rem limit frame dimensions
Set /A "linesLimit=50"
Set /A "linesAboveLimit=16"
Set /A "linesBelowLimit=16"
Set /A "leftMargLimit=50" & rem limit optional left margin
If %superWidth% gtr %widthLimit% Set "superWidth=%widthLimit%"
If %superHeight% gtr %linesLimit% Set "superHeight=%linesLimit%"
If %superHeight% gtr 0 Set "linesLimit=%superHeight%"
If %linesBelow% gtr %linesBelowLimit% Set "linesBelow=%linesBelowLimit%"
If %linesAbove% gtr %linesAboveLimit% Set "linesAbove=%linesAboveLimit%"
If %marginLeft% gtr %leftMargLimit% Set "marginLeft=%leftMargLimit%"
If "%side%"=="CENTER" Set "side=+" & Set "marginLeft=0"
If "%side%"=="RIGHT" Set "side=-" & Set "marginLeft=0"
If "%side%"=="LEFT" Set "side="
setlocal EnableDelayedExpansion
Set numLines=1
Set maxLen=1
If %actionCode% equ 4 GoTo:lineArrayEdit & rem frame will be filled with a character
If %actionCode% equ 1 Set /p file=<_source_.txt
If %actionCode% geq 2 If %actionCode% leq 3 Set "file=_source_.txt"
rem count the number of lines in file
For /f %%j In ('Type %file%^|Find "" /v /c') Do Set /A numLines=%%j
If %linesAbove% gtr 0 (
For /L %%n In (1,1,%linesAbove%) Do Set "line[%%n]= "
Set /A baseCount+=%linesAbove%+1
Set /A numLines=%numLines%+%linesAbove%
) Else (
Set baseCount=1
)
If %numLines% gtr %linesLimit% Set /A numLines=%linesLimit%
Set /A n=%numLines%+%linesBelow%
If %n% gtr %linesLimit% Set /A numLines-=%linesBelow%
rem Read file lines and get max line length
< "%file%" (For /L %%i In (%baseCount%,1,%numLines%) Do (
Set "line[%%i]="
Set /P "line[%%i]="
Set "strA=!line[%%i]!"
If Not "!strA!"=="" Set "strA=!strA:_blank_= !"
Set "line[%%i]=!strA!"
Set "strA=0!strA!"
Set "len=0"
For /L %%a In (8,-1,0) Do (
Set /A "newLen=len+(1<<%%a)"
For %%b In (!newLen!) Do If "!strA:~%%b,1!" neq "" Set "len=%%b"
)
If !len! gtr !maxLen! Set "maxLen=!len!"
If !len! equ 0 Set "line[%%i]= "
))
:lineArrayEdit
If %superHeight% gtr 0 Set /A numLines=%superHeight%
If %marginLeft% gtr 0 (
rem add left margin to each line
Set "space="
For /L %%i In (1,1,%marginLeft%) Do Set "space= !space!"
Set /A maxLen+=%marginLeft%
For /L %%i In (1,1,%numLines%) Do (
If not "!line[%%i]!"==" " (
Set "str=!space!!line[%%i]!"
Set "line[%%i]=!str!"
)))
If not "%superWidth%"=="0" (
If "%superWidth:~0,1%"=="-" (
Set /A "maxLen-=%superWidth:~1%"
) Else If "%superWidth:~0,1%"=="+" (
Set /A "maxLen+=%superWidth:~1%"
) Else (
If %superWidth% gtr 0 Set /A maxLen=%superWidth%
))
If %maxLen% gtr %widthLimit% Set maxLen=%widthLimit%
If %maxLen% leq 0 Set "maxLen=1"
If %superHeight% gtr 0 (
rem add enough blank lines to make a fixed-height frame
For /L %%i In (%superHeight%,-1,1) Do (
If not defined line[%%i] (Set "line[%%i]= ") Else GoTo:ABdone
)
)
:ABDone
If %linesBelow% gtr 0 If %numLines% lss %linesLimit% (
rem add lines to end of array
For /L %%n In (1,1,%linesBelow%) Do (
Set /A numLines+=1
If !numLInes! lss %linesLimit% Set "line[!numLines!]= "
))
If %superHeight% gtr 0 If %linesBelow% gtr 0 (
rem assign blank space to array elements for lines added to bottom of fixed-height frame
Set /A x=%numLines%
For /L %%n In (%linesBelow%,-1,1) Do (
Set "line[!x!]= "
Set /A x-=1
))
::borderSetup
If not "%border%"=="NONE" (
If "%border%"=="THIN" (
Set bdrTotal=%maxLen%
Set "UL=218" & Set "UR=191"
Set "LL=192" & Set "LR=217"
Set "HZ=196" & Set "VT1=179" & Set "VT2=!VT1!"
Set "topHoriz=!UL! !HZ!*%maxLen% !UR!"
Set "botHoriz=!LL! !HZ!*%maxLen% !LR!"
) Else If "%border%"=="SPLIT" (
Set bdrTotal=%maxLen%
Set "UL=201" & Set "UR=187"
Set "LL=200" & Set "LR=188"
Set "HZ=205" & Set "VT1=186" & Set "VT2=!VT1!"
Set "topHoriz=!UL! !HZ!*%maxLen% !UR!"
Set "botHoriz=!LL! !HZ!*%maxLen% !LR!"
) Else (
Set /A bdrTotal=%maxLen%+4
If %asciiCode% leq 31 Set "v1Factor=*1"
If %asciiCode2% leq 31 Set "v2Factor=*1"
Set "UL=%asciiCode%" & Set "UR=%asciiCode%"
Set "LL=!UL!" & Set "LR=!UL!" & Set "HZ=!UL!"
Set "topHoriz=!HZ!*!bdrTotal!"
Set "botHoriz=!topHoriz!"
If not "%asciiCode%"=="%asciiCode2%" (
If "%isReverse%"=="R" (
Set "VT1=%asciiCode%!v1Factor! %asciiCode2%!v2Factor!" & Set "VT2=%asciiCode2%!v2Factor! %asciiCode%!v1Factor!"
) Else If "%isReverse%"=="RL" (
Set "VT1=%asciiCode%!v1Factor! %asciiCode2%!v2Factor!" & Set "VT2=%asciiCode%*2"
) Else If "%isReverse%"=="RR" (
Set "VT1=%asciiCode%*2" & Set "VT2=%asciiCode2%!v2Factor! %asciiCode%!v1Factor!"
) Else (
rem vertical border ascii chars. will not be reversed
Set "VT1=%asciiCode%!v1Factor! %asciiCode2%!v2Factor!" & Set "VT2=%asciiCode%!v1Factor! %asciiCode2%!v2Factor!"
)
) Else (
Set "VT1=%asciiCode%*2" & Set "VT2=!VT1!"
)))
::batch file prep
If "%saveBAT%"=="_RESERVED$_" GoTo:cleanUp & rem this tool's filename was entered as output filename
If %actionCode% leq 2 If not "%saveBAT%"=="0" (
For /L %%i In (1,1,%numLines%) Do (
rem to write literal percent chars to a batch file, double them, if found
If not "!line[%%i]"==" "! (
Set "str=!line[%%i]!"
Set "str=!str:%%=%%%%!"
Set "line[%%i]=!str!"
)))
::target line colorization
For /L %%x In (1,1,5) Do If "!target%%x!"=="_FALSE_" (Set target%%x=) Else Set "isTarget=TRUE"
If "%isTarget%"=="TRUE" (
For /L %%x In (1,1,5) Do (
If defined target%%x If not defined WholeWordTarg (
If "!target%%x:.=!" equ "!target%%x!" (Set "WholeWordTarg=TRUE") Else Set "WholeWordTarg=FALSE"
)))
If "%WholeWordTarg%"=="TRUE" (
rem for whole word targets, add a leading & trailing space to each line.
For /L %%n In (1,1,%numLines%) Do (
If not "!line[%%n]!"==" " (
Set "str= !line[%%n]! "
Set "line[%%n]=!str!"
)))
For /L %%x In (1,1,5) Do (
If defined target%%x (
Set "target%%x=!target%%x:[_]=[underscore]!"
Set "target%%x=!target%%x:_= !"
Set "target%%x=!target%%x:[underscore]=_!"
Set "target%%x=!target%%x:[literalcolon]=:!"
Set "target%%x=!target%%x:[scolon]=;!"
Set "target%%x=!target%%x:[comma]=,!"
Set "target%%x=!target%%x:[asterisk]=*!"
Set "target%%x=!target%%x:[openparen]=(!"
Set "target%%x=!target%%x:[closeparen]=)!"
If "!target%%x:~-1!"=="." (
Set "target%%x=!target%%x:~0,-1!"
) Else (
Set "target%%x= !target%%x! " & rem add leading, trailing space
)))
If Not "%LineColors1%"=="X" If "%target1%"=="" Set "altColors=TRUE"
::function calls to deliver the output
If "%saveBAT%"=="0" (Call :showFrame) Else Call :writeBatch
:cleanUp
If EXIST _params_.txt DEL _params_.txt
If EXIST _source_.txt DEL _source_.txt
endlocal & endlocal & exit /b
:: ______________________________functions begin here______________________________
:showFrame
rem construct string of parameters & display the frame--no batch file written
Set "params="
If defined eBorder If not "%border%"=="WIDE" Set /A bdrTotal+=2
If %fillCode% gtr 0 (Set "line_content=%fillCode%*%maxLen%") Else Set "line_content=line[%%i]"
If defined indent Set "indentStr=/07 32*%indent%"
If defined indentStr Set "params=%indentStr%"
If defined eBorder (Set "params=%params% /%eBorder% 218 196*%bdrTotal% 191 13 10") Else Set "params="
If defined bdrColors (
If defined eBorder (
If "%topHZOut%"=="FALSE" (
Set "params=%params% %indentStr% /%eBorder% 179 /%bdrColors% %topHoriz% /%eBorder% 179 13 10"
)
) Else (
If "%params%"=="" If defined indentStr Set "params=%indentStr%"
If "%topHZOut%"=="FALSE" Set "params=!params! /%bdrColors% %topHoriz% 13 10"
)
)
If "%params%"=="%indentStr%" Set "params="
For /L %%i In (1,1,%numLines%) Do (
Set "tColors=X"
Set "str=!line[%%i]!"
Set "isTarget=FALSE"
If not "%file%"=="_info_.txt" If not "!str: =!"=="" (
For /L %%x In (1,1,5) Do (
If not "!LineColors%%x!"=="X" If not "!target%%x!"=="" If "!isTarget!"=="FALSE" (
Set "targ=!target%%x!"
Set "str=!line[%%i]!"
Call Set "str=%%str:^!=[EXCLAMATION]%%"
Call :targetCk "!str!" "!targ!" isTarget
If "!isTarget!"=="FALSE" (Set "tColors=%textColors%") Else Set "tColors=!LineColors%%x!"
)))
If "%altColors%"=="TRUE" (
Set "tColors=!LineColors1!"
Set /A r=%%i%%2
If !r! equ 1 (Set "txtColors=!LineColors1!" & Set "tColors=X") Else Set "txtColors=%textColors%"
)
If not "!tColors!"=="X" (Set "txtColors=!tColors!" & Set "tColors=X") Else Set "txtColors=%textColors%"
If defined eBorder (
Set "params=!params! %indentStr% /%eBorder% 179 /%bdrColors% %VT1% /!txtColors! %line_content%:%side%%maxLen% /%bdrColors% %VT2% /%eBorder% 179 13 10"
) Else (
Set "params=!params! %indentStr% /%bdrColors% %VT1% /!txtColors! %line_content%:%side%%maxLen% /%bdrColors% %VT2% 13 10"
))
If defined eBorder (
If "%botHZOut%"=="FALSE" If defined bdrColors Set "params=%params% %indentStr% /%eBorder% 179 /%bdrColors% %botHoriz% /%eBorder% 179 13 10"
) Else (
If "%botHZOut%"=="FALSE" If defined bdrColors Set "params=%params% %indentStr% /%bdrColors% %botHoriz% 13 10"
)
If defined eBorder Set "params=%params% %indentStr% /%eBorder% 192 196*%bdrTotal% 217 13 10"
If "%file%"=="_info_.txt" If EXIST _info_.txt DEL _info_.txt
ColorShow %params%
If "%pauser%"=="TRUE" pause
exit /b
::_______________________end showFrame____________________________________________
:targetCk
rem assign TRUE to %3 var if %1 contains %2
setlocal DisableDelayedExpansion
Set "str1=%~1"
endlocal & set "str1=%str1%"
setlocal EnableDelayedExpansion
If "!str1:%~2=!"=="%str1%" (Set "isTarget=FALSE") Else Set "isTarget=TRUE"
endlocal & set "%~3=%isTarget%" & exit /b
::_______________________end targetCk_____________________________________________
:writeBatch
rem write a batch file that displays the frame, run batch file
If defined eBorder If not "%border%"=="WIDE" Set /A bdrTotal+=2
If %actionCode% equ 4 (Set "line_content=%fillCode%*%maxLen%") Else Set "line_content=line[%%%%i]"
If %indent% gtr 0 Set "iString=/07 32*%indent%"
Set /p pars=<_params_.txt
Set "pars=%pars: = %"
>"%saveBAT%" (
Echo @Echo Off
Echo rem frame parameters: %pars%
If %actionCode% geq 3 (Echo setlocal EnableDelayedExpansion) Else Echo setlocal DisableDelayedExpansion
If %fillCode% equ 0 (
For /L %%i In (1,1,%numLines%) Do (
Echo Set ^"line[%%i]^=!line[%%i]!^"
)
Set "line_content=line[%%%%%i]"
)
Echo Set ^"numLines=%numLines%^"
If "%altColors%"=="TRUE" (
Echo Set /A x=0
) Else (
For /L %%x In (1,1,5) Do (
If defined target%%x (
Set "target%%x=!target%%x:_= !"
If "!target%%x:~-1!"=="." (
Echo Set "target%%x=!target%%x:~0,-1!"
) Else (
Echo Set "target%%x=!target%%x:_=!"
))))
If %actionCode% leq 2 Echo setlocal EnableDelayedExpansion
Set "params="
If defined eBorder (
If defined iString (
Echo Set "params=%iString% /%eBorder% 218 196*%bdrTotal% 191 13 10"
) Else (
Echo Set "params=/%eBorder% 218 196*%bdrTotal% 191 13 10"
))
If not "%border%"=="NONE" If "%topHZOut%"=="FALSE" (
If defined eBorder (
Set "str=Set "params=%%params%% %iString% /%eBorder% 179 /%bdrColors% %topHoriz% /%eBorder% 179 13 10""
) Else (
If "%topHZOut%"=="FALSE" (
Set "str=Set "params=%%params%% %iString% /%bdrColors% %topHoriz% 13 10""
)
)
Set "str=!str: = !"
If not "!str!"==" " Echo !str!
)
Echo(
Echo For /L %%%%i In ^(1,1,%%numLines%%^) Do ^(
If "%altColors%"=="TRUE" (
Echo Set /A x=%%%%i%%%%2
Set "string=If ^!x^!==1 (Set "tColors^=%textColors%") Else Set "tColors^=%LineColors1%""
Echo !string!
Set "txtColors=^!tColors^!"
) Else (
Set "txtColors=%textColors%"
)
If not "%altColors%"=="TRUE" (
For /L %%x In (1,1,5) Do (
If not "!LineColors!%%x"=="X" If defined target%%x (
If %%x equ 1 Echo Set "str=^!line[%%%%i]^!"
If %%x equ 1 (
Echo If "^!str:%%target%%x%%=^!"=="^!line[%%%%i]^!" (Set "tColors=%textColors%"^) Else Set "tColors=!LineColors%%x!"
) Else (
Echo If not "^!str:%%target%%x%%=^!"=="^!line[%%%%i]^!" Set "tColors=!LineColors%%x!"
))))
If "%altColors%"=="TRUE" (
Set "txtColors=^!tColors^!"
) Else (
If not "!target1!"=="" Set "txtColors=^!tColors^!"
)
If defined eBorder (
Set "str=Set "params=^^!params^^! %iString% /%eBorder% 179 /%bdrColors% %VT1% /!txtColors! !line_content!:%side%%maxLen% /%bdrColors% %VT2% /%eBorder% 179 13 10""
) Else (
Set "str=Set "params=^^!params^^! %iString% /%bdrColors% %VT1% /!txtColors! !line_content!:%side%%maxLen% /%bdrColors% %VT2% 13 10""
)
Set "str=!str: = !"
Echo !str!
Echo ^)
Echo(
If not "%border%"=="NONE" If "%botHZOut%"=="FALSE" (
If defined eBorder (
Set "str=Set "params=%%params%% %iString% /%eBorder% 179 /%bdrColors% %botHoriz% /%eBorder% 179 13 10""
) Else (
Set "str=Set "params=%%params%% %iString% /%bdrColors% %botHoriz% 13 10""
)
Set "str=!str: = !"
If not "!str!"==" " Echo !str!
)
If defined eBorder Echo Set "params=%%params%% %iString% /%eBorder% 192 196*%bdrTotal% 217 13 10"
Echo ColorShow %%params%%
If "%pauser%"=="TRUE" For /F "tokens=*" %%a In ("pause") Do Echo %%a
If %actionCode% leq 2 (Echo endlocal ^& endlocal) Else Echo endlocal
)
If not "%skipRun%"=="TRUE" Echo( & endlocal & Call "%saveBAT%"
exit /b
::_______________________end writeBatch___________________________________________
:paramsValidate [parameters] [ret parameters] [ret gridParams] [ret eBorder] [ret topHZOut] [botHZOut] [ret skipRun]
rem check command-line parameters isolated by vbscript.
rem returned formatting parameters and gridParams are delimited strings
setlocal EnableDelayedExpansion
Set "params=%~1"
Set "border=NONE"
Set "fillCode=0" & Set "isFill=FALSE"
Set "indent=0"
Set "superWidth=0" & Set "superHeight=0"
Set "marginLeft=0"
Set "linesAbove=0" & Set "linesBelow=0"
Set "pauser=FALSE"
Set "side=CENTER"
Set "skipRun=FALSE"
Set "params=%params:;=[scolon]%"
Set "params=%params:,=[comma]%"
Set "topHZOut=FALSE" & Set "botHZOut=FALSE"
Set asciiCode=
Set asciiCode2=
For %%t In (%params%) Do (
Set "str=%%t"
If "!str:~0,1!"=="/" (
If "!str:~0,2!"=="/A" Set "aColors=!str:~2!"
If "!str:~0,2!"=="/B" Set "bColors=!str:~2!" & Set "border=WIDE"
If "!str:~0,2!"=="/C" Set "gBdrCode=!str:~2!"
If "!str:~0,2!"=="/E" Set "eBorder=!str:~2!" & set "xTraBorder=TRUE"
If "!str:~0,2!"=="/F" Set "saveBAT=!str:~2!"
If "!str:~0,2!"=="/G" Set "gridParams=!str:~2!"
If "!str:~0,2!"=="/H" Set "superHeight=!str:~2!"
If "!str:~0,2!"=="/I" Set "indent=!str:~2!"
If "!str:~0,2!"=="/K" Set "bColors=!str:~2!" & Set "border=SPLIT"
If "!str:~0,2!"=="/L" Set "bColors=!str:~2!" & Set "border=THIN"
If "!str:~0,2!"=="/M" Set "marginLeft=!str:~2!"
If "!str:~0,2!"=="/O" Set "LineColors1=!str:~2!"
If "!str:~0,2!"=="/P" Set "pauser=TRUE"
If "!str:~0,2!"=="/Q" Set "skipRun=TRUE"
If "!str:~0,2!"=="/S" Set "LineColors2=!str:~2!"
If "!str:~0,2!"=="/T" Set "LineColors3=!str:~2!"
If "!str:~0,2!"=="/U" Set "LineColors4=!str:~2!"
If "!str:~0,2!"=="/V" Set "LineColors5=!str:~2!"
If "!str:~0,2!"=="/W" Set "superWidth=!str:~2!"
If "!str:~0,2!"=="/X" Set "fillCode=!str:~2!" & Set "isFill=TRUE"
If "!str:~0,2!"=="/Y" Set "linesAbove=!str:~2!"
If "!str:~0,2!"=="/Z" Set "linesBelow=!str:~2!"
) Else (
If "!str!"=="RIGHT" Set "side=RIGHT"
If "!str!"=="LEFT" Set "side=LEFT"
If "!str!" neq "RIGHT" If "!str!" neq "LEFT" (
rem check for integer(s) in range 1-255 to display ascii character
For %%n In (!str!) Do (
If "!asciiCode!"=="" (
Call :bdrCharValidate "%%n" asciiCode asciiCode2 isReverse
)))))
Call :numComponent "%indent%" indent & rem ensure that vars are numeric
Call :numComponent "%superHeight%" superHeight
Call :numComponent "%marginLeft%" marginLeft
Call :numComponent "%superWidth%" superWidth "+" "-"
Call :numComponent "%linesAbove%" linesAbove
Call :numComponent "%linesBelow%" linesBelow
If "%isFill%"=="TRUE" (
Call :numComponent "%fillCode%" fillCode
If !fillCode! lss 1 Set "fillCode=1"
If !fillCode! gtr 255 Set "fillCode=255"
)
Set /A "n=0"
rem parse colon-delimited color code from underscore-delimited text (0e:word_or_words)
For %%x In (LineColors1 LineColors2 LineColors3 LineColors4 LineColors5 eBorder) Do (
Set /A n+=1
If defined %%x (
Set "%%x=!%%x:[:]=[literalColon]!"
For /F "tokens=1,2* delims=:" %%a In ("%%x") Do (
For /F "tokens=1,2* delims=:" %%r In ("!%%a!") Do Set "c1=%%r" & Set "t1=%%s"
Set "LineColors!n!=!c1!"
Set "target!n!=!t1!"
)))
If "%eBorder%"=="" If "%xTraBorder%"=="TRUE" Set "eBorder=07"
If "%isFill%"=="TRUE" If defined gridParams (
For /F "tokens=1,2* delims=:" %%a In ("%gridParams%") Do Set "accr=%%a" & Set "down=%%b" & Set "eColors=%%c"
Call :numComponent "!accr!" accr
If !accr! lss 1 Set "accr=1"
If !accr! gtr 60 Set "accr=60"
Call :numComponent "!down!" down
If !down! equ 0 Set "down=1"
If !down! gtr 50 Set "down=50"
If defined eColors (
Set "gBdrCode=0"
Call :colorsValidate "!eColors!" eColors
) Else (
Set "eColors=X"
)
If not "%gBdrCode%"=="" (
Call :numComponent "%gBdrCode%" gBdrCode
If "!gBdrCode!"=="0" Set "gBdrCode=32"
) Else (
Set "gBdrColors=X" & Set "gBdrCode=0"
)
Set "gridParams=!accr!:!down!:!gBdrCode!:!eColors!"
If defined LineColors1 (
If not defined target1 Set "target1=32"
Set "gridParams=!gridParams!:%LineColors1%:!target1!"
)
) Else (
Set "gridParams=0"
)
If defined altColors (
For /L %%x In (1,1,5) Do (
Set /A t=%%x
Set "str=!target%%x!"
If defined !str! (
rem convert multiple-words target (if any) to space-delimited words
Set "target!t!=!str!"
Set "target!t!=!str:[_]=[literalUScore]!"
Set "target!t!=!str:_=[blank]!"
Set "target!t!=!str:[literalUScore]=_!"
Set "target!t!=!str:[blank]= !"
)))
If not "%bColors%"=="" (
If not "!bColors:++=!"=="!bColors!" Set "xOpt=NA"
If not defined xOpt If not "!bColors:+-=!"=="!bColors!" Set "topHZOut=FALSE" & Set "botHZOut=TRUE" & Set "xOpt=TRUE"
If not defined xOpt If not "!bColors:--=!"=="!bColors!" Set "topHZOut=TRUE" & Set "botHZOut=TRUE" & Set "xOpt=TRUE"
If not defined xOpt If not "!bColors:-+=!"=="!bColors!" Set "topHZOut=TRUE" & Set "botHZOut=FALSE" & Set "xOpt=TRUE"
If not defined xOpt If not "!bColors:++=!"=="!bColors!" Set "topHZOut=FALSE" & Set "botHZOut=FALSE" & Set "xOpt=TRUE"
If not defined xOpt If not "!bColors:-=!"=="!bColors!" Set "topHZOut=TRUE" & Set "botHZOut=FALSE"
)
If defined bColors (
Set "bColors=%bColors:+=%"
If defined bColors Set "bColors=!bColors:-=!"
)
If not "%border%"=="NONE" If not defined bColors Set "bColors=07"
For %%a In (aColors bColors LineColors1 LineColors2 LineColors3 LineColors4 LineColors5) Do (
If defined %%a (
Call :colorsValidate !%%a! retCodes
Set "%%a=!retCodes!"
))
If not defined aColors Set "aColors=07"
If not defined bColors Set "bColors=07"
If not defined LineColors1 Set "LineColors1=X"
If not defined LineColors2 Set "LineColors2=X"
If not defined LineColors3 Set "LineColors3=X"
If not defined LineColors4 Set "LineColors4=X"
If not defined LineColors5 Set "LineColors5=X"
If not defined target1 Set "target1=_FALSE_"
If not defined target2 Set "target2=_FALSE_"
If not defined target3 Set "target3=_FALSE_"
If not defined target4 Set "target4=_FALSE_"
If not defined target5 Set "target5=_FALSE_"
If not defined asciiCode Set "asciiCode=176"
If not defined asciiCode2 Set "asciiCode2=%asciiCode%"
If not defined isReverse Set "isReverse=FALSE"
If not defined saveBAT Set "saveBAT=0"
If not defined gridParams Set "gridParams=0"
rem delimit parameters to be returned
Set "retVals=%side%~%border%~%aColors%~%bColors%~%indent%~%superWidth%~"
Set "retVals=%retVals%%superHeight%~%linesAbove%~%linesBelow%~"
Set "retVals=%retVals%%asciiCode%~%asciiCode2%~%isReverse%~%fillCode%~%marginLeft%~"
Set "retVals=%retVals%%LineColors1%~%target1%~%LineColors2%~%target2%~"
Set "retVals=%retVals%%LineColors3%~%target3%~%LineColors4%~%target4%~"
Set "retVals=%retVals%%LineColors5%~%target5%~%pauser%~%saveBAT%"
endlocal & set "%~2=%retVals%" & set "%~3=%gridParams%" & set "%~4=%eBorder%" & set "%~5=%topHZOut%" & set "%~6=%botHZOut%" & set "%~7=%skipRun%" & exit /b
::_______________________end paramsValidate_______________________________________
:colorsValidate [color code(s)] [return var]
rem examine one or two chars for DOS color codes 0-9 A-F.
rem if one is valid and one is not, use only the valid code.
rem example arg: 0e
setlocal EnableDelayedExpansion
Set "char1=%~1"
Set "char2=%char1:~1,1%"
Set "char1=%char1:~0,1%"
Set "char1Found=FALSE"
Set "char2Found=FALSE"
Set "chars=A B C D E F 0 1 2 3 4 5 6 7 8 9"
For /D %%a In (%chars%) Do If %%a==%char1% Set "char1Found=TRUE"
For /D %%a In (%chars%) Do If %%a==%char2% Set "char2Found=TRUE"
Set "colorCodes=%char1%%char2%"
If "%char1Found%"=="TRUE" If "%char2Found%"=="FALSE" Set "colorCodes=%char1%%char1%"
If "%char1Found%"=="FALSE" If "%char2Found%"=="TRUE" Set "colorCodes=%char2%%char2%"
rem otherwise keep both non-valid codes and let colors be assigned from those characters
endlocal & Set "%~2=%colorCodes%"& exit /b
::_______________________end colorsValidate_______________________________________
:bdrCharValidate [string to check] [asciiCode ret var] [asciiCode2 ret var] [isReverse ret var]
rem validate %1 for numeric value or two delimited values in the range 1-255.
rem look for 'R' option at end of %1 and, if found, set isReverse var to TRUE to reverse
rem right-hand vertical border characters. If 'RR' found then right vertical border
rem will have a variation and left vertical border will not, and the opposite for 'RL'.
setlocal EnableDelayedExpansion
Set "str=%~1"
Set "isReverse="
Set "isVar=TRUE"
For /F "tokens=1* delims=:" %%a In ("%str%") Do Set "val1=%%a" & Set "val2=%%b"
If not "%val2%"=="" (
Set "val2=%val2::=%"
If "!val2:~-2!"=="LR" Set "val2=!val2:LR=RL!"
If "!val2:~-2!"=="RR" (
Set "isReverse=RR" & Set "val2=!val2:~0,-2!"
) Else If "!val2:~-2!"=="RL" (
Set "isReverse=RL" & Set "val2=!val2:~0,-2!"
)
If not defined isReverse If "!val2:~-1!"=="R" Set "isReverse=R" & Set "val2=!val2:~0,-1!"
If defined isReverse (Set "val2=!val2:R=!") Else Set "isReverse=FALSE"
)
Call :numComponent "%val1%" val1
If not "%val2%"=="" Call :numComponent "%val2%" val2
If "%val2%"=="" (Set /A loopCount=1) Else Set /A loopCount=2
For /L %%n In (1,1,%loopCount%) Do (
Set "var=val%%n"
Set /A "x=!val%%n!"
If !x! lss 1 (
Set !var!=1
) Else If !x! gtr 255 (
Set !var!=255
))
rem if ascii char is restricted, change it to a blank
For /L %%n In (1,1,%loopCount%) Do (
For %%c In (7 8 9 10 13) Do If %%c equ !val%%n! Set "val%%n=32"
)
If "%val2%"=="" Set "val2=%val1%"
endlocal & Set "%~2=%val1%" & Set "%~3=%val2%" & set "%~4=%isReverse%" & exit /b
::_______________________end bdrCharValidate______________________________________
:bNameValidate [filename entry] [validated name ret var]
rem determine entry or non-entry of a valid batch filename, return filename or 0
setlocal EnableDelayedExpansion
Set "batName=%~1"
If "%batName%"=="F" Set "batName=0"
If not "%batName%"=="" (
Set "batName=%batName:-="%"
Set "batName=!batName:+="!"
If not "!batName: =!"=="" Call :compare2strings "!batName!" "%~n0" isMatch
If not "!batName!"=="0" (
If "!isMatch!"=="TRUE" (
Echo That batch filename is reserved. Try another.
Set "batName=_RESERVED$_"
GoTo :exitBNV
)
For %%a In ("!batName!") Do If /I not "%%~xa"==".BAT" Set "batName=!batName!.bat"
))
:exitBNV
If "%batName%"=="" Set "batName=0"
endlocal & set "%~2=%batName%" & exit /b
::_______________________end bNameValidate________________________________________
:gridMaker [gridSpecs] [frmColors] [bdrColors] [fillCode] [indent] [width] [height] [pauser] [skipRun]
setlocal EnableDelayedExpansion
Set "gridSpecs=%~1"
Set "frmColors=%~2" & Set "bdrColors=%~3"
Set "fillCode=%~4"
Set "indent=%~5"
Set "width=%~6" & Set "height=%~7"
Set "pauser=%~8"
Set "skipRun=%~9"
Set "gridparams="
Set "altColors=" & Set "altCode="
Set "lineStart= "
Set "outFile="
Set /p gPars=<_params_.txt
Set "gPars=%gPars: = %"
For %%c In (7 8 9 10 13) Do If %%c equ %fillCode% Set "fillCode=32"
Call :numComponent "%width%" width
Call :numComponent "%height%" height
For /F "tokens=1-9 delims=:" %%a In ("%gridSpecs%") Do (
Set "outFile=%%a"
Set "bdrType=%%b"
Set "accr=%%c" & Set "down=%%d"
Set "gBdrCode=%%e" & Set "gBdrColors=%%f"
Set "altColors=%%g" & Set "altCode=%%h"
)
If defined altColors (
Set "altColors=%altColors:~0,2%"
If defined altCode (
Set "str=%altCode%"
If not "!str:~0,1!"=="0" (
Call :numComponent "!str!" str
If "!str!"=="0" (
Set "altCode=32"
) Else (
If !str! geq 1 If !str! leq 255 Set "altCode=!str!"
))
Call :numComponent "!altCode!" altCode
For %%c In (7 8 9 10 13) Do If %%c equ !altCode! Set "altCode=32"
) Else (
Set "altCode=%fillCode%"
))
If "%outFile%"=="0" (
Set "outFile=grid.bat"
) Else (
For %%a In ("!outFile!") Do If /I not "%%~xa"==".BAT" Set "outFile=!outFile!.bat"
)
If %width% lss 1 Set "width=2"
If %height% lss 1 Set "height=1"
If %width% gtr 50 If %accr% neq 1 Set "width=50"
If %width% gtr 100 Set "width=100"
If %width% equ 1 If %height% gtr 40 Set "height=40"
If %height% gtr 50 Set "height=50"
If %accr% equ 1 (Set "spcA=") Else Set "spcA= "
If %down% equ 1 (Set "spcD=") Else Set "spcD= "
If %height% equ 1 Set "altColors=" & Set "altCode="
If not "%altColors%"=="" (
If %accr% geq 1 If %down% geq 1 Set "addedSpc= "
If %accr% equ 1 If %down% gtr 1 Set "addedSpc= "
If %accr% geq 2 If %down% geq 2 Set "addedSpc= "
) Else (
Set "addedSpc="
)
If %accr% gtr 1 If %height% gtr 1 Set "addedSpc= "
Set /A hzWide=(%accr%*%width%)+(%accr%*2)
If %indent% gtr 0 (
If %indent% gtr 1 (Set "lineStart=/07 32*%indent%") Else Set "lineStart=/07 32"
) Else (
Set "lineStart=" & Set "indentStr="
)
Set "indentStr=%lineStart%
If not "%gBdrCode%"=="0" (
For %%x In (7 8 9 10 13) Do If %%x==%gBdrCode% Set "xCode=TRUE"
If "!xCode!"=="TRUE" Set "gBdrCode=32"
If !gBdrCode! leq 31 (Set "gBC=!gBdrCode!*1") Else Set "gBC=!gBdrCode!"
)
If not "%gBdrCode%"=="0" (
Set "UL=%gBdrCode%" & Set "UR=%gBC%"
Set "LL=%gBdrCode%" & Set "LR=%gBC%"
Set "HZ=%gBdrCode%" & Set "VT1=%gBC%" & Set "VT2=!VT1! 13 10"
If %gBdrCode% leq 31 Set "UL=!UL!*1" & Set "LL=!LL!*1"
) Else If "%bdrType%"=="SPLIT" (
Set "UL=201" & Set "UR=187"
Set "LL=200" & Set "LR=188"
Set "HZ=205" & Set "VT1=186" & Set "VT2=!VT1! 13 10"
) Else (
Set "UL=218" & Set "UR=191"
Set "LL=192" & Set "LR=217"
Set "HZ=196" & Set "VT1=179" & Set "VT2=!VT1! 13 10"
)
If not "%gBdrColors%"=="X" (
Set /A hzWide=%accr%*%width%
Set /A hzWide+=%accr%*2
Set /A totalWidth=!hzWide!+2
If %indent% gtr 0 (
If not "%gBdrCode%"=="0" (
Set "topHZ=%indentStr%/%gBdrColors% %HZ%*!totalWidth! 13 10%lineStart%/%gBdrColors% %VT1%"
Set "botHZ=%indentStr%/%gBdrColors% %HZ%*!totalWidth! 13 10"
) Else (
Set "topHZ=%indentStr%/%gBdrColors% %UL% %HZ%*!hzWide! %UR% 13 10 %lineStart%/%gBdrColors% %VT1%"
Set "botHZ=%indentStr%/%gBdrColors% %LL% %HZ%*!hzWide! %LR% 13 10"
)
) Else (
If "%UL%"=="%UR%" (
Set "topHZ=/%gBdrColors% %HZ%*!totalWidth! 13 10 %VT1%"
Set "botHZ=/%gBdrColors% %HZ%*!totalWidth! 13 10"
) Else (
Set "topHZ=/%gBdrColors% %UL% %HZ%*!hzWide! %UR% 13 10 %VT1%"
Set "botHZ=/%gBdrColors% %LL% %HZ%*!hzWide! %LR% 13 10"
))
Set "lineStart=!lineStart!/%gBdrColors% !VT1!"
Set "lineEnd=/%gBdrColors% %VT2%"
) Else (
Set "lineEnd=13 10"
)
If "%topHZOut%"=="TRUE" (
If %gBdrCode% equ 0 (Set "HZ=%VT1%") Else Set "HZ=%gBdrCode%
)
setlocal DisableDelayedExpansion
If %down% equ 1 (Set "chrs=%%%%") Else Set "chrs=^^^!"
endlocal & Set "chrs=%chrs%"
> "%outFile%" (
Echo @Echo Off
Echo rem grid parameters: %gPars%
Echo setlocal EnableDelayedExpansion
Echo(
If not "%gBdrColors%"=="X" (
Echo Set "gridparams="
) Else (
If %indent% gtr 0 (
Echo Set ^"gridparams=%lineStart%^"
) Else (
Echo Set "gridparams="
))
If not "%gBdrColors%"=="X" (
If "%topHZOut%"=="FALSE" (
Echo Set "gridparams=%%gridparams%%!topHZ!"
) Else (
Echo Set "gridparams=%%gridparams%% %indentStr%/%gBdrColors% %HZ%*1
))
Echo(
If %down% gtr 1 (
Echo For /L %%%%r In ^(1,1,%down%^) Do ^(
Echo(
)
If %accr% gtr 1 (
Echo %spcD%For /L %%%%t In ^(1,1,%accr%^) Do Set "gridparams=^!gridparams^!/%bdrColors% 218 196*%width% 191^"
) Else (
Echo %spcD%Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1!/%bdrColors% 218 196*%width% 191"
)
If %indent% equ 0 (
If "%gBdrColors%"=="X" (
Set "string=Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1! %lineEnd%""
) Else (
Set "string=Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1!%lineEnd%/%gBdrColors% %VT1%""
)
) Else (
If "%gBdrColors%"=="X" (
Set "string=Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1! %lineEnd%%lineStart%""
) Else (
Set "string=Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1!%lineEnd%%lineStart%""
))
Echo %spcD%!string!
Echo(
If %height% gtr 1 Echo %spcD%For /L %%%%h In ^(1,1,%height%^) Do ^(
If defined altColors (
If %down% equ 1 (Echo %addedSpc%Set /A x=%%%%h%%%%2) Else Echo %spcD%%addedSpc%Set /A x=%%%%h%%%%2
If defined altCode (
Set "string=%addedSpc%If ^!x^!==1 ^(Set "tColors=%frmColors%" ^& Set "frmFill=%fillCode%") Else Set "tColors=%altColors%" ^& Set "frmFill=%altCode%""
Set "frmFill=^^!frmFill^^!"
) Else (
Set "string=%spcA%%spcD%If ^!x^!==1 ^(Set "tColors=%frmColors%") Else Set "tColors=%altColors%""
Set "frmFill=%fillCode%"
)
Echo %spcD%!string!
If %accr% gtr 1 (
Echo %spcA%%spcD%For /L %%%%a In ^(1,1,%accr%^) Do Set "gridparams=^!gridparams^!/%bdrColors% 179/^!tColors^! ^!frmFill^!*%width%/%bdrColors% 179^"
) Else (
Echo %spcD%%addedSpc%Set "gridparams=^!gridparams^!/%bdrColors% 179/^!tColors^! ^!frmFill^!*%width%/%bdrColors% 179^"
)
) Else (
If %accr% gtr 1 (
If %height% equ 1 Set "spcA="
Echo !spcA!%spcD%For /L %%%%a In ^(1,1,%accr%^) Do Set "gridparams=^!gridparams^!/%bdrColors% 179/%frmColors% %fillCode%*%width%/%bdrColors% 179^"
) Else (
If %height% gtr 1 Set "spcA= "
If %accr% gtr 1 Set "spcA= "
Echo !spcA!%spcD%%addedSpc%Set "gridparams=^!gridparams^!/%bdrColors% 179/%frmColors% %fillCode%*%width%/%bdrColors% 179^"
))
If not "%gBdrColors%"=="X" If %accr% gtr 1 Set "spcA="
If "%gBdrColors%"=="X" (
Echo !spcA!%spcD%Set "gridparams=^!gridparams^! %lineEnd%!%lineStart%"
) Else (
Set "string=!spcA!%spcD%%addedSpc%Set "gridparams=^^!gridparams^^!%lineEnd%!%lineStart%""
Echo !string: /=/!
)
If %height% gtr 1 Echo %spcD%^)
Echo(
If %accr% gtr 1 (
Echo %spcD%For /L %%%%b In ^(1,1,%accr%^) Do Set "gridparams=^!gridparams^!/%bdrColors% 192 196*%width% 217^"
) Else (
Echo %spcD%Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1!/%bdrColors% 192 196*%width% 217"
)
If "%gBdrColors%"=="X" (
Echo %spcD%Set "gridparams=!chrs:~1,1!gridparams!chrs:~1,1! %lineEnd%"
) Else (
If %down% gtr 1 (Echo %spcD%Set "gridparams=^!gridparams^!%lineEnd%") Else Echo Set "gridparams=%%gridparams%%%lineEnd%"
rem If %down% gtr 1 (Echo %spcD%Set "gridparams=^!gridparams^!%lineEnd%") Else Echo %spcD%Set "gridparams=%%gridparams%%%lineEnd%"
)
If "%gBdrColors%"=="X" (
If %down% gtr 1 (
If not "%lineStart%"=="" Echo %spcD%If %%%%r lss %down% Set "gridparams=^!gridparams^!%lineStart%"
)
) Else (
If %down% gtr 1 (
Set "string=If %%%%r lss %down% Set "gridparams=^^!gridparams^^! %indentStr%/%gBdrColors% %VT1%""
) Else (
Set "string=Set "gridparams=^^!gridparams^^! %indentStr%/%gBdrColors% %VT1%""
)
If %down% gtr 1 Echo %spcD%!string: /=/!
)
If %down% gtr 1 Echo ^) & Echo(
If not "%gBdrColors%"=="X" If "%botHZOut%"=="FALSE" Echo Set "gridparams=%%gridparams%%!botHZ!"
If %down% equ 1 Echo(
Echo ColorShow %%gridparams%%
If "%pauser%"=="TRUE" For /F "tokens=*" %%a In ("pause") Do Echo %%a
Echo endlocal
)
If "%skipRun%"=="FALSE" Call %outFile%
endlocal & exit /b
::_______________________end gridMaker____________________________________________
:infoReq [command-line args]
rem call for the requested tool information.
setlocal EnableDelayedExpansion
Set "str=%~1"
If "%str:~0,2%"=="/?" Set "str=?"
Set "infoPage=0"
If "%str:~0,1%"=="?" (
Set "infoPage=!str:~1!"
Call :numComponent "!infoPage: =!" infoPage & rem retrieve numeric value
) Else (
rem check for a number 1-9
For /L %%n In (1,1,9) Do If "%str%"=="%%n" Set "infoPage=%%n"
)
If not "%infoPage%"=="0" (
Set "str=INF"
) Else (
Set "str=%str:?=INF%"
Set "str=!str:~0,3!"
)
If "%str%"=="INF" Call :showInfo "%infoPage%"
If "%str%"=="ASC" Call :asciiTable
If "%str%"=="COL" Call :colorChart
endlocal & exit /b
::_______________________end infoReq______________________________________________
:showInfo [option]
setlocal EnableDelayedExpansion
Set /A "option=%~1"
Set "panels= ABCDEFGHI"
Set "choices= q"
If "%infoFrmColors%"=="" Set "infoFrmColors=07"
If "%infoBdrColors%"=="" Set "infoBdrColors=07"
If %option% equ 0 (
Set "panels=A B C D E F G H I"
) Else (
For %%i In (!option!) Do Set "panels=!panels:~%%i,1!"
)
For %%a In (%panels%) Do (
If !errorlevel! equ 3 GoTo:exitSI
Call :infoPanels "%%a"
Call "%~f0" left /a%infoFrmColors% /b%infoBdrColors% 177 /i2 /m2 /w82 _info_.txt
Echo(
If %option%% gtr 0 (
pause
) Else (
If not "%%a"=="I" (
<nul set /p "=Press spacebar to Continue, q to Quit>>> "
Echo(
Call :choice %choices%
) Else ( pause
)))
:exitSI
endlocal & exit /b
::_______________________end showInfo_____________________________________________
:infoPanels
setlocal
Set "panel=%~1"
>"_info_.txt" (
for /f "tokens=1,* delims=:@" %%a in ('findstr /n "^@:%panel%" "%~f0" ') do (
Set "line=%%b"
If "%%b"=="%panel%" (Echo( ) Else Echo !line:~2!
))
endlocal & exit /b
::_______________________end infoPanels___________________________________________
:infoToFile
rem save text from info panels in a file
setlocal EnableDelayedExpansion
If EXIST infoDoc.txt DEL infoDoc.txt
Set "panels=A B C D E F G H I"
>>"infoDoc.txt" (
For %%a In (%panels%) Do (
Set "panel=%%a%"
Echo(
For /f "tokens=1,* delims=:@" %%a In ('findstr /n "^@:!panel!" "%~f0" ') do (
Set "line=%%b"
If "%%b"=="!panel!" (Echo() Else Echo !line:~2!
)))
If EXIST infoDoc.txt (Echo infoDoc.txt file written) Else Echo infoDoc.txt file was not written
endlocal & exit /b
::_______________________end infoToFile___________________________________________
:asciiTable
rem display a table of ascii characters and codes in the range 1-255
setlocal EnableDelayedExpansion
Set /A c=1
Set /A counter=17
Set "params=32*31 /0b ^"ASCII Characters _and_ Codes^" 13 10"
Set "params=%params% 32 /07 218 /07 196*85 /07 191 13 10"
For /L %%i In (1,1,15) Do (
Set "numbs="
For /L %%n In (!c!,1,!counter!) Do (
Set "str= %%n %"
Set "str=!str:~-5!"
Set "numbs=!numbs!!str!"
)
For /L %%t In (!c!,1,!counter!) Do (
Set "xCode="
For %%x In (7 8 9 10 13) Do If %%x==%%t Set "xCode=TRUE"
Set /A s=%%t & Set /A s-=1
Set /A s=!s!%%17+1
If "!xCode!"=="" (
If %%t leq 31 (Set "c!s!=%%t*1!") Else Set "c!s!=%%t"
) Else (
Set "c!s!=32"
))
Set "params=!params! 32 179 /07 ^"!numbs!^" 179 13 10"
Set "params=!params! 32 /07 179 32*3 /0e !c1! 32*4 !c2! 32*4 !c3! 32*4 !c4! 32*4 !c5!"
Set "params=!params! 32*4 !c6! 32*4 !c7! 32*4 !c8! 32*4 !c9! 32*4 !c10! 32*4 !c11! 32*4"
Set "params=!params! !c12! 32*4 !c13! 32*4 !c14! 32*4 !c15! 32*4 !c16! 32*4 !c17! 32 /07 179 13 10"
Set /A counter+=17
Set /A c=!counter!-16
)
Set "params=%params% 32 /07 192 196*85 217 13 10"
Echo(
ColorShow %params:_and_=^&%
pause
endlocal & exit /b
::_______________________end asciiTable___________________________________________
:colorChart
setlocal EnableDelayedExpansion
Set "c=0 1 2 3 4 5 6 7 8 9 a b c d e f"
Set "codes= "
Set /A k=0
For %%b In (%c%) Do Set "codes=!codes! %%b"
Set "params=/07 32 /0e "%codes%" 13 10"
Set "params=%params% /07 32 218 196*82 191 13 10"
For %%j In (%c%) Do (
Set "params=!params! /07 32 179 /0e ^"%%j^" 32"
For %%m In (%c%) Do (
Set "params=!params! 32 /%%j%%m ^" %%j%%m ^""
Set /A k+=1
Set /A m=!k!%%16
If !m! equ 0 Set "params=!params! /07 179 13 10"
))
Set "params=%params% /07 32 192 196*82 217 13 10"
Echo(
ColorShow %params%
pause
endlocal & exit /b
::_______________________end colorChart___________________________________________
:numComponent [string] [return var] [char. #1] [char. #2]
rem return numeric component at trailing end of string or return 0.
rem return + or - with the number when %3 and %4 are assigned.
setlocal
Set "chars=%~1"
Set "chars=%chars: =%"
Set "validChars=0 1 2 3 4 5 6 7 8 9 %~3 %~4"
Set "numbs="
rem save numeric characters at end of string until non-numeric char is found.
:topNC
Set "numer="
Set "temp=%chars:~-1%"
For %%i In (%validChars%) Do If "%temp%"=="%%i" Set "numer=%%i" & GoTo:nextNC
:nextNC
If not "%numer%"=="" (Set "numbs=%numer%%numbs%") Else GoTo:endNC
Set "chars=%chars:~0,-1%"
GoTo:topNC
:endNC
If "%numbs%"=="" Set "numbs=0"
If "%~3"=="" Set /A numbs=%numbs%*1
endlocal & set "%~2=%numbs%" & exit /b
::_______________________end numericComponent_____________________________________
:compare2strings [new batch filename] [this batch filename] [return var]
rem compare batch filenames in %1 and %2 after converting to uppercase
rem purpose: prevent this batch file from being overwritten
setlocal EnableDelayedExpansion
Set "bat1=%~1"
Set "bat1=%bat1:.BAT=%"
Set "bat2=%~2"
For /L %%i In (1,1,2) Do (
Set "strng=!bat%%i!"
For /F "delims=" %%a In ("!strng!") Do (
Set "chrs=%%a"
For %%b In (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) Do (
Set "chrs=!chrs:%%b=%%b!"
))
Set "chrs%%i=!chrs!"
)
If "%chrs1%"=="%chrs2%" (Set "isMatch=TRUE") Else Set "isMatch=FALSE"
endlocal & set "%~3=%isMatch%" & exit /b
::_______________________end compare2strings______________________________________
:choice
setlocal
Set KEY=
Set "errlvl="
For /f "delims=" %%a In ('Xcopy /l /W "%~f0" "%~f0" 2^>nul') Do (
If Not defined KEY Set "KEY=%%a"
)
Set KEY=%KEY:~-1%
setlocal EnableDelayedExpansion
If "%KEY%"=="" Set "errlvl=0"
If "%KEY%"==" " Set "errlvl=0"
If /I "%KEY%"=="Q" Set "errlvl=3"
If not "%errlvl%"=="" endlocal & endlocal & exit /b %errlvl%
endlocal & GoTo:choice
::_______________________end choice_______________________________________________