Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#1 Post by Jer » 02 Apr 2016 23:57

5/22/2016 - documentation revision: part 2 of batch file, panel 6 of 9, "/g:#:#:#" changed to "g/#:#:.." Third element is color codes, not a number.

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 :oops: 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_______________________________________________
Last edited by Jer on 22 May 2016 10:30, edited 40 times in total.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#2 Post by Jer » 03 Apr 2016 16:57

I found two areas of the tool that had to be corrected, and noted at the top of
the file what the revisions are.

samples.bat was also revised. When a frame is filled with an ascii character
with the /X option, the /W and /H options will give the frame width and height.
The /Z option (lines below) will also give the frame height, but the /Y option (lines above) will not.

Thanks for your patience.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#3 Post by foxidrive » 05 Apr 2016 08:16

Jer wrote:Thanks for your patience.


I have that, but complex things need sleep to focus eyes on and I don't have that. Just replying to give you an indication that your post has been noted - and it sounds good.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#4 Post by Jer » 30 Apr 2016 19:43

Here is the lower half for FrameTool.bat. Copy this code to the bottom of the batch file.
samples.bat is at the bottom of this post. (edited 5/9/2016)

Code: Select all

@:A Frametool.bat is a batch-vbscript hybrid that constructs a string of
@:A parameters for ColorShow.exe to display text on a bordered background.
@:A
@:A Use this tool by passing coded parameters and text or text source,
@:A either from the DOS command-line or from another batch file.
@:A
@:A The parameters entered define the frame horizontal position, colors,
@:A size, margins, and content of the framed area.
@:A
@:A Tool options:
@:A    1. make frame - text comes from a file
@:A    2. make frame - text string entered from the command-line
@:A    3. fill frame lines with standard characters
@:A    4. fill frame lines with a single character from ascii codes 1-255
@:A    5. make a grid of frames
@:A    6. display color chart
@:A    7. display ascii table of printable characters
@:A    8. display one or more information panels
@:A    9. write tool documentation to text file
@:A
@:A Example command-line arguments:
@:A    ?     <view this documentation>
@:A    3     <view only panel #3 of documentation>
@:A    colors
@:A    ascii
@:A    file  <write this documentation to a text file>
@:A    /ae4 /b1f 177 /i4 /w+8 {Your Message}
@:A    left /a60 /L0e /i2 /m3 /w+3 /fNewBatchFile sourcefile.txt
@:A    /a3b /b2f /i1 /g2:2:b3 /obe:6 /c176 /w7 /h5 /x176
@:A
@:A                                1 of 9
@:B
@:B Option #1 reads lines from a text file and presents the lines on a
@:B framed background that has a width determined by the longest line of
@:B text.  A border can be added using the /b option.  Command-line entries
@:B define frame indentation, text justification, left and right margins,
@:B colorization of border and text area, and can assign frame dimensions.
@:B
@:B Formatting parameters, if any, are entered first followed by the
@:B name of the text file.  All lines of the file will be displayed,
@:B up to 50 lines and a maximum of 150 columns.
@:B Lines can be all Centered, or Left or Right justified.
@:B
@:B In this example:
@:B frametool left /a1e /b08 178 /i4 /m2 /w+4 /fsplash myownfile.txt
@:B
@:B the tool writes a batch file named splash.bat that invokes ColorShow
@:B with the command-line arguments to:
@:B
@:B    left justify the text
@:B    assign text area colors of light yellow font on blue
@:B    make a surrounding border with gray font on black
@:B    fill the border with ascii character for code 178
@:B    indent the frame 4 columns
@:B    add a 2-column left margin inside the frame
@:B    set text width to calculated text width +4
@:B    display contents of myownfile.txt on a uniform-width background
@:B
@:B                                2 of 9
@:B
@:C
@:C For option #2, curly bracketed text is entered following the formatting
@:C parameters.  This will display one or more lines from the bracketed
@:C entry.  Bracketed text must be the last thing entered on the command-
@:C line or when calling this tool from another batch file.
@:C
@:C {my text} displays 'my text' on a single line. { my text } adds a blank line
@:C before and after the words. {  my text  } adds the lines and an additional
@:C column in the left and right margins.
@:C
@:C {some words[n]more words[n]last words} will display the text on three lines.
@:C
@:C examples:
@:C
@:C    /b {Your Line of Text Here
@:C    /a2f /be /w+4 { Line of Text }
@:C    /a1e /b2a 179 /i6 /w+8 { I said "Hello World^!" }
@:C    /a2f /L71 /i1 /w+4 { 4 characters must have a caret: ^& ^< ^> ^| }
@:C    /ab1 /b3f 186 /i10 /w20 {  Main Menu  }
@:C    /a80 /b93 178:177r /i3 /w+10 /y2 /z2 {text[n][n]more text[n][n]last text}
@:C    /a8 /be4 176:177r /i1 /w40 /z10 {}
@:C    /a9 /b1 /i2 /w25 /z6 {}
@:C    /ae0 /bf3-- 14:179r /e07 /i3 /w+6 /y4 /z4 {Concert Tonight[n][n]8:00PM}
@:C
@:C                                3 of 9
@:C
@:D
@:D Option #3 takes numeric values following the /D and /R codes to fill the
@:D frame with standard ascii characters. 'D' duplicates lines and 'R' repeats
@:D characters entered x number of times, i.e., /d9 /r4 would display a total
@:D of 10 lines and the characters or word(s) would be repeated on each line
@:D for a total of 5 per line.
@:D
@:D example:
@:D
@:D   left /ae4 /ba4 /i4 /w-2 /d6 /r8 {^|__
@:D
@:D
@:D Option #4 is a frame filled with a printable ascii character in the ascii
@:D code range 1-255.  Enter /X immediately followed by the ascii code.
@:D Options /H and /W will give height and width dimensions to the frame.
@:D
@:D The following makes a bordered frame with six lines filled with ascii
@:D char. 180 and writes the file mysplash.bat that will display the frame.
@:D
@:D    /a1e /L8b /i6 /w10 /h6 /x180 /fmysplash
@:D
@:D Option #5 makes a grid of frames.  Depth is defined by the /g code.  Codes /h
@:D and /w give the individual grid frames height and width. A border around the
@:D grid is added with a color code: /g3:3:0c (red thin-line border) or
@:D /k /g3:3:0c (red split-line border).  Use /o code with this option to assign
@:D alternate fill character and colors to alternate frame lines:  /o1b:178
@:D Example 3x3 grid: /a6e /b8f /i1 /g3:3:80 /o9b:254 /w7 /h4 /fMyGrid /x248
@:D Pages 6 & 9 have some information about the grid option.
@:D
@:D                                4 of 9
@:D
@:E
@:E              Text Alignment, Text Coloring & Border Codes
@:E
@:E  left           - left justify all text
@:E  right          - right justify all text
@:E                 - center alignment is the default
@:E
@:E  /a..           - text area background & foregound colors:  /a3f
@:E                 - a single color code will display a solid color
@:E
@:E  /b             - add default border around text area
@:E  /b.            - border w/solid color: /b4
@:E  /b.. ###       - border w/background & foreground colors & char:  /b1e 179
@:E  /b.. ###:###r  - vertical border variation:  /b1e 179:178R
@:E                   <uses 2 chars, chars reversed in right vertical border>
@:E  /b.. ###:###RR - variation on right vertical only:  /b1e 177:178RR
@:E  /b.. ###:###RL - variation on left vertical only:  /b1e 177:178RL
@:E  /b..--         - border horizontals not displayed:  /b2--
@:E  /b..-          - top border horizontal not displayed:  /b2-
@:E  /b..+-         - bottom border horizontal not displayed:  /b4+-
@:E
@:E  /k..           - two thin lines border:  /k0e
@:E  /L..           - single thin line border:  /L0e
@:E  /E..           - add thin-line outer border-frame only, not grid: /e9b
@:E
@:E                                5 of 9
@:E
@:F                       More Frame Definition Codes
@:F
@:F  /d# /r#    - # lines duplicated, repeat x times per line: /d4 /r14
@:F
@:F  /g#:#:..    - grid of frames: /g[#across]:[#down]:[border colors]  /g4:4:07
@:F               (default output: grid.bat, or name a file with /f.  see pg. 9)
@:F  /c###      - grid outer border character:  /c240
@:F
@:F  /h##       - fixed # of lines in frame: /h24
@:F
@:F  /i##       - indent the whole display ## columns:  /i4
@:F
@:F  /m#        - # of columns in left margin when text is left justified:  /m2
@:F
@:F  [n]        - for text entry only:  {add a new[n]line[n][n]or two}
@:F
@:F  /o##       - assign colors to alternate lines:  /o70
@:F  /o##:targ  - assign colors to lines with target word: /o0e:word
@:F  /o##:targ. - assign colors to lines with target characters: /o0e:mp3.
@:F               (see notes about this code and codes /s /t /u /v on pg. 7)
@:F
@:F  /o..:###   - grid only-colors & char. for alternate lines:  /obe:27
@:F
@:F  /w##       - override text area width:  /w40
@:F  /w-#       - reduce text area width by #:  /w-1
@:F  /w+##      - increase text area width by #:  /w+10
@:F
@:F  /x###      - ascii code for character to fill text area: /X180
@:F
@:F  /y#        - add # lines to top of frame:  /y3
@:F  /z#        - add # lines to bottom of frame:  /z4
@:F
@:F                                6 of 9
@:G                       Other Command-line Codes
@:G
@:G /p   -  add line of code at end of new batch file to pause
@:G
@:G /q   -  supress the immediate display of the new frame.  To be effective,
@:G         give a name to the new batch file, i.e., /fMyFileName
@:G         and the file is saved for editing or later use.
@:G ________________________________________________________________________
@:G The /o parameter code can be used to set colors of alternate lines,
@:G but also to assign colors to individual lines based on a text target.
@:G Setting colors to targeted lines can also be done with codes /s /t /u /v.
@:G
@:G Do not include these characters in the text target:   { ~ | < > " & ^
@:G If saving in batch, do not enter ^! as a target character.
@:G
@:G Enter one or more underscores to represent a space or spaces.
@:G To include an underscore in the text, enter [_]
@:G To include a colon in the text, enter [:]
@:G To assign colors to lines with a percent character, for characters
@:G enter %%%%. or if free-standing enter a target like this: 100%%%%
@:G
@:G /o8e:word
@:G    set colors 8e to lines with the free-standing word 'word'
@:G /o8e:word1_word2
@:G    set line colors to 8e if 'word1 word2' occurs on the line
@:G /o8e:word1[_]word2
@:G    treats this target as two words separated by an underscore
@:G /o8e:chars. (note the period)
@:G    set line colors to 8e if the characters 'chars' occur on the line
@:G
@:G When a whole word or words are the target, "This is on one line." becomes
@:G " This is on one line. " in the displayed frame.
@:G
@:G                                7 of 9
@:H
@:H This tool handles all standard ascii characters including & < > | ^!
@:H and % when these characters are in a text file and the frame is being
@:H displayed within the tool.
@:H
@:H For the curly bracketed text option, a literal ampersand requires a leading
@:H caret (^), as well as do the symbols < > and |.
@:H
@:H About the fill code: /X..., for example /X181 fills the text area with
@:H ascii char. for code 181, including grids.  When this code is used, any
@:H entry of curly bracketed text or a filename as a text source is ignored.
@:H
@:H A new batch file is saved and run when you provide a filename with the
@:H /F code, i.e., /fMyBatch.  For single frames, without a filename, the frame
@:H is displayed by a function in this tool and not saved.  A grid of frames is
@:H always saved in a batch file; the default filename is grid.bat.
@:H
@:H ColorShow.exe from DOSTIPS website is required and must be in the
@:H same folder as this batch file.
@:H
@:H Your prepared text file must be in the same folder and have no
@:H spaces or characters in the filename that would need to be escaped.
@:H
@:H If you create a text file by copying and pasting from a source that
@:H used characters from a different character set than standard ascii, you
@:H may find that some of those characters appear different than expected.
@:H
@:H                                8 of 9
@:H
@:I
@:I Rules when calling this tool from another batch file:
@:I
@:I When calling with a call command and your text string includes any of
@:I these special characters < > | &, put the text in a file first:
@:I
@:I >"temp.txt" (For /F "tokens=*" %%a In ("& <<<|>>>") Do Echo %%a)
@:I
@:I followed by batch code like this example:
@:I     call frametool.bat /a4e /Lb4 /i4 /w+6 /y2 /z2 temp.txt
@:I
@:I To display a literal % character when using the batch file call command,
@:I quadruple the character:
@:I     call frametool.bat /a3f /L2c /i3 { 25%%%% off }
@:I ________________________________________________________________________
@:I If saving a frame in a batch file and the text includes double quotes
@:I with other special characters, skip running the new batch file by adding
@:I the /q code, then edit the new batch file and insert a caret where needed
@:I to escape & | < > characters in the array of text lines.
@:I ________________________________________________________________________
@:I When entering text for display and you want to show literal curly brackets
@:I on the end of a line, add two extra trailing spaces:
@:I             /a2f /b8 /w+6 {Curly Bracket symbols: {}  }
@:I ________________________________________________________________________
@:I Grid of frames is limited to whatever contents can fit into a single variable.
@:I If the number of elements and size exceed this limit, the grid will appear
@:I truncated at the bottom.  Reduce one or more /g parameters until you get a
@:I complete grid.  A grid example:  /aeb /b38 /g6:3:b6 /w5 /h3 /fMyGrid /x178
@:I Include color codes on the end of the /g code to add a surrounding border.
@:I
@:I                                9 of 9
@:I


----- Begin wsf script --->

<job><script language="VBScript">

' separate parameters from text, or text source; write to two files.
' an opening curly bracket indicates that what follows is a text string for display
' or possibly one or more blanks.
' no bracket(s) are entered if the text source is a file.
' could also be a request to fill frame with an ascii character, standard
' characters, or to display batch tool info.

'one of these error levels will be returned by the script:
' 0=request type not determined
' 1=text comes from a file
' 2=text string was entered
' 3=creating a frame of standard characters filled lines
' 4=creating a frame of single character-filled lines (ascii 1-255)
' 5=display color chart
' 6=display ascii table
' 7=display one or more info panels
' 8=write tool documentation to text file

Option Explicit
Dim  objFSO, objPARAMSFile, objSRCFile, objTextStream
Dim strLine, brktIndex, idx, idx2, text_source
Dim params, actionCode, srcFile, paramsFile, isFile, isBorder
Dim newbatch, endSpace, str, str1, str2, temp
Dim intgr, dupCount, counter
Dim upperLine, lowerLine, repeat, strArray()

Set objFSO = CreateObject("Scripting.FileSystemObject")
strLine = WScript.Arguments(0)
srcFile = "_source_.txt"
paramsFile = "_params_.txt"
actionCode = 0
isFile = FALSE
upperLine = FALSE
lowerLine = FALSE
repeat = 1

'+ may have been inadvertently included with these parameters:
str = "dhimryz"
For intgr = 1 To len(str)
   temp = Mid(str, intgr, 1)
   strLine = Replace(strLine, "/"&temp&"+", "/"&temp)
   strLine = Replace(strLine, "/"&UCase(temp)&"+", "/"&temp)
Next

strLine = Replace(strLine, "/", " /")
strLine = Replace(strLine, "  /", " /")
strLine = Replace(strLine, "[N]", "[n]")

temp = UCase(strLine)
If InStr(temp, "/F") > 0 Then
   'preserve batch filename letter case
   idx = InStr(temp, "/F")
   temp = Mid(strLine, idx+2) & " "
   idx2 = InStr(temp, " ")
   newBatch = Mid(strLine, idx, idx2+1)
   strLine = Replace(strLine, newBatch, "")
   newBatch = "/F" & Mid(newBatch, 3)
   newBatch = Replace(newBatch, "d_~_q", "")
End If

'look for request to display tool info: one or all the info panels,
'or the colors chart or ascii table.
str = UCase(Replace(strLine, "/", ""))
str = Replace(str, " ", "")

If str = "?" Then
   Call writeTxtSrc ("_info_.txt")
   actionCode = 8
End If

If actionCode = 0 Then
   str = Replace(str, "?", "")
   If len(str) = 1 Then
      For intgr = 1 To 9
         If str = CStr(intgr) Then
            actionCode = 8
            Call writeParams(intgr, "")
            Exit For
         End If
      Next
   Else
      If Left(str, 3) = "COL" Then actionCode = 6
      If Left(str, 3) = "ASC" Then actionCode = 7
      If Left(str, 4) = "FILE" Then actionCode = 9
   End If
End If

If actionCode = 8 Then Call writeTxtSrc("_info_.txt")
If actionCode <> 0 Then WScript.Quit actionCode

brktIndex = InStr(strLine, "{")

If brktIndex <> 0 Then
   'isolate bracketed text that is on the end of the input string
   If brktIndex = 1 Then
      text_source = strLine
   Else
      str1 = UCase(Mid(strLine, 1, (brktIndex-1)))
      text_source = Mid(strLine, brktIndex)
      If Right(str1, 1) = " " Then str1 = Mid(str1, 1, (len(str1)-1))
   End If
Else
   str1 = UCase(strLine)
End If

If text_source <> "" Then
   If InStr(text_source, "d_~_q") > 0 Then text_source = Replace(text_source, "d_~_q", """")
End If

If brktIndex <> 0 Then
   'if empty brackets or bracketed blanks were entered, change blanks to '_blank_' for conversion in batch
   str = Replace(text_source, "{", "")
   str = Replace(str, "}", "")
   If Replace(str, " ", "") = "" Then text_source = Replace(text_source, " ", "_blank_")
   If text_source = "{}" Then text_source = "{_blank_}"
End If

If str1 <> "" Then
   'check for /G option to make a grid of frames. this option has first priority
   If InStr(str1, "/G") > 0 Then
      actionCode = 5
      If InStr(str1, "/X") = 0 Then str1 = "/X32 " & str1
      If InStr(str1, "/H") = 0 Then str1 = "/H1 " & str1
      If InStr(str1, "/W") = 0 Then str1 = "/W1 " & str1
      If InStr(str1, "/B") > 0 Then isBorder = True
      If InStr(str1, "/L") > 0 Then isBorder = True
      If InStr(str1, "/K") > 0 Then isBorder = True
      If not isBorder Then str1 = "/B " & str1 'grid frames always have borders
      Call writeParams (UCase(str1), newBatch)
      WScript.Quit actionCode
   End If
End If

If str1 <> "" Then
   'check for /X option where ascii char fills the frame. this option has next priority
   If InStr(str1, "/X") > 0 Then
      actionCode = 4
      Call writeParams (UCase(str1), newBatch)
      WScript.Quit actionCode
   End If
End If

If brktIndex > 0 Then
  If Right(text_source, 2) = " }" Then
     text_source = Mid(text_source, 1, (len(text_source)-2))
     If Right(strLine, 4) = "}  }" Then
        'curly bracket is literal
        lowerLine = FALSE
     Else
        lowerLine = True
     End If
  ElseIf Right(text_source, 1) = "}" Then
     text_source = Mid(text_source, 1, (len(text_source)-1))
  End If
  If Left(text_source, 2) = "{ " Then
     upperLine = True
     text_source = Mid(text_source, 3)
  Else
     text_source = Mid(text_source, 2)
  End If
End If

idx = InStr(str1, "/D")
If idx = 0 Then
   If InStr(str1, "/R") > 0 Then
      str1 = "/D0 " & str1
      idx = 1
   End If
End If
If idx > 0 Then
   If InStr(str1, "/R") = 0 Then
      str1 = "/R0 " & str1
      idx = idx +4
   End If
End If

If str1 <> "" And idx > 0 Then
   dupCount = Mid(str1, (idx+2)) & " "
   idx = InStr(dupCount, " ")
   dupCount = Mid(dupCount, 1, (idx-1))

   If not isNumeric(dupCount) Then dupCount = 1

   'if text is in a file, get the 1st line in the file for duplication
   If text_source = "" Then
      idx = InStrRev(strLine, " ")
      str = Mid(strLine, (idx+1))
      If (objFSO.FileExists(str)) Then
         Set objSRCFile = objFSO.OpenTextFile(str, 1, FALSE, 0)
         text_source = objSRCFile.ReadLine
         objSRCFile.Close
      Else
         text_source = "_blank_"
      End If
   End If
   actionCode = 3
   params = str1

   idx = InStr(params, "/R")
   If idx > 0 Then
      upperLine = FALSE
      lowerLine = FALSE
      'repeat text on one or more lines
      repeat = Mid(params, (idx+2)) & " "
      idx = InStr(repeat, " ")
      repeat = Mid(repeat, 1, (idx-1))
      If not isNumeric(repeat) Then repeat = 1
      text_source = Replace(text_source, "[n]", vbNewLine)
      text_source = Replace(text_source, "[N]", vbNewLine)
      If text_source = "" Then text_source = " "

      Set objSRCFile = objFSO.CreateTextFile(srcFile)
      objSRCFile.WriteLine(text_source)
      objSRCFile.Close

      Set objTextStream = objFSO.OpenTextFile("_source_.txt", 1, False, 0)
      ReDim Preserve strArray(1)

      'put line or lines that will be duplicated into array
      Do While Not objTextStream.AtEndOfStream
         str = objTextStream.ReadLine
         If str <> "" Then
            ReDim Preserve strArray(UBound(strArray)+1)
            strArray(UBound(strArray)-1) = str
         End If
      Loop
      objTextStream.Close

      If strArray(UBound(strArray)) = "" Then ReDim Preserve strArray(UBound(strArray)-1)
      'repeat text or characters on each line if /R option used
      For idx = 1 To UBound(strArray)
         str1 = strArray(idx)
         str2 = str1
         For idx2 = 1 To repeat
           str2 = str2 & str1
         Next
         strArray(idx) = str2
      Next

      text_source = ""
      intgr = (dupCount+1) * UBound(strArray)
      counter = 0

      For idx2 = 1 To (dupCount+1)
         For idx = 1 To UBound(strArray)
           counter = counter + 1
           If counter < intgr Then
               text_source = text_source & strArray(idx) & vbNewLine
            Else
               text_source = text_source & strArray(idx)
            End If
         Next
      Next

      Call writeParams (UCase(params), newBatch)
      Call writeTxtSrc(text_source)
      WScript.Quit actionCode
   End If
End If

'if double border is requested, verify or add #1 border to parameters
If InStr(str1, "/E") > 0 Then
   If InStr(str1, "/B") > 0 Then isBorder = True
   If InStr(str1, "/L") > 0 Then isBorder = True
   If InStr(str1, "/K") > 0 Then isBorder = True
   If not isBorder Then str1 = "/B07 " & str1
End If

If text_source <> "" Or brktIndex > 0 Then
   actionCode = 2
   'prepare bracketed text and write to file
   If Left(text_source, 2) = "{ " Then
      upperLine = True
      text_source = Mid(text_source, 3)
   Else
      text_source = Mid(text_source, 1)
   End If

   If Right(text_source, 2) = " }" Then
      lowerLine = True
      text_source = Mid(text_source, 1, (len(text_source)-2))
   Else
      If Right(text_source, 1) = "}" Then text_source = Mid(text_source, 1, (len(text_source)-1))
   End If
   If str1 <> "" Then Call writeParams(str1, newBatch)
   Call writeTxtSrc(text_source)

   WScript.Quit actionCode
End If

'look for filename of existing file
idx = InStrRev(strLine, " ")
If idx > 0 Then
   str = Mid(strLine, (idx+1))
Else
   str = strLine
End If

If objFSO.FileExists(str) Then
   actionCode = 1
   Call writeTxtSrc(str)
   If idx > 0 Then
      params = Mid(strLine, 1, (idx-1))
      If Right(params, 1) = " " Then params = Mid(params, 1, (len(params)-1))
      Call writeParams(params, newBatch)
   End If
End If

WScript.Quit actionCode

'______________________subroutines begin here__________________________
Sub writeParams (string, newBatch)
Dim char, chars, index, isTarget
string = Replace(string, "*", "[asterisk]")
string = Replace(string, "(", "[openparen]")
string = Replace(string, ")", "[closeparen]")
string = Replace(string, "!", "[exclamation]")
string = Replace(string, "d_~_q", "")

If InStr(UCase(string), "/O") > 0 And Mid(string, InStr(UCase(string), "/O")+4,1) <> " " Then isTarget = True
If InStr(UCase(string), "/S") > 0 And Mid(string, InStr(UCase(string), "/S")+4,1) <> " " Then isTarget = True
If InStr(UCase(string), "/T") > 0 And Mid(string, InStr(UCase(string), "/T")+4,1) <> " " Then isTarget = True
If InStr(UCase(string), "/U") > 0 And Mid(string, InStr(UCase(string), "/U")+4,1) <> " " Then isTarget = True
If InStr(UCase(string), "/V") > 0 And Mid(string, InStr(UCase(string), "/V")+4,1) <> " " Then isTarget = True

chars = "&|<>*@#$%^():=;[]{}~\,'`""-?+"
For index = 1 To len(chars)
   char = Mid(chars, index, 1)
   If InStr(newBatch, char) > 0 Then newBatch = Replace(newBatch, char, "")
Next

If isTarget Then
   'remove these chars from parameter code entries
   chars = "!&|<>^()"
Else
   'following chars do not apply to frame parameter codes; remove if found.
   chars = "&|<>*@#$^()=[]{}~\,'`""?"
End If

For index = 1 To len(chars)
   char = Mid(chars, index, 1)
   If InStr(string, char) > 0 Then string = Replace(string, char, "")
Next

For index = 1 To 5
   string = Replace(string, "  ", " ")
Next

string = UCase(string) & " " & newBatch
If Right(string, 1) = " " Then string = Mid(string, 1, Len(string)-1)

Set objPARAMSFile = objFSO.CreateTextFile(paramsFile)
objPARAMSFile.WriteLine(string)
objPARAMSFile.Close
End Sub
'____________________________________________________________________________________________________

Sub writeTxtSrc (txtsrc)
Set objSRCFile = objFSO.CreateTextFile(srcFile)
If InStr(txtsrc, "[n]") > 0 Then txtsrc = Replace(txtsrc, "[n]", vbNewLine)

If upperLine Then objSRCFile.WriteLine("_blank_")
objSRCFile.WriteLine(txtsrc)
If lowerLine Then objSRCFile.WriteLine("_blank_")

objSRCFile.Close
End Sub

</script></job>


samples.bat

Code: Select all

@Echo Off
setlocal EnableDelayedExpansion
Set "prg=frametool.bat"
Set "choices= q" & Set "count=29"

If /I "%1"=="G" (
   Set "loopStart=22"
) Else If not "%1"=="" (
   For /L %%n In (1,1,%count%) Do  If "%1"=="%%n" Set "loopStart=%%n
) Else (
    Set "loopStart=1"
)

If not defined loopStart Set "loopStart=1"

For /L %%n In (%loopStart%,1,%count%) Do (
   Echo( & Echo %%n of %count%
   Call :frm!%%n
   <nul set /p "=Press spacebar to Continue, q to Quit>>> "
   Echo(
   Call :choice %choices%
   If !errorlevel! equ 3 GoTo:exitSamples
)

:exitSamples
If EXIST temp.txt DEL temp.txt
endlocal & exit /b

:frm1
echo( & echo batch code:
Echo Set "str=/a0c /b5f /i6 /w+8 /o0b:just /s0d:few /t0a:words /u09:brought /v0e:you"
Echo Set "str=%%str%% { Just a[n]few[n]words[n]brought[n]to you[n]in colors }"
Set "str=/a0c /b5f /i6 /w+8 /o0b:just /s0d:few /t0a:words /u09:brought /v0e:you"
Set "str=%str% { Just a[n]few[n]words[n]brought[n]to you[n]in colors }
echo call %prg% %%str%%
Call %prg% %str%
goto:eof

:frm2
echo( & echo code entered from command-line:
echo %prg% left /a8 /b /o70 /d4 /r4 /y1 {[n]  e-z read  [n]  }
call %prg% left /a8 /b /o70 /d4 /r4 /y1 {[n]  e-z read  [n]  }
goto:eof

:frm3
call :makeTxt
echo( & echo The following shows the behavior of the codes /H (fixed height)
echo  /Y (lines above) and /Z (lines below) working together.  What you are
echo seeing is that a frame with added blank lines and a fixed-height will display
echo only the number of file lines that will fit in the remaining framed area. & echo(
echo call %prg% /a0a /b /w+10 /y2 /z2 /h12 temp.txt
call frametool.bat /a0a /b /w+10 /y2 /z2 /h12 temp.txt
goto:eof

:frm4
echo( & echo batch code:
echo call %prg% /a3e /b41 178 /i2 /w+8 /y2 /z2 {Discounted 50%%%%%%%% if you call now![n][n](888) 888-8888}
echo( & echo or from the command-line
echo %prg% /a3e /b41 178 /i2 /w+8 /y2 /z2 {Discounted 50%% if you call now![n][n](888) 888-8888}
call %prg% /a3e /b41 178 /i2 /w+8 /y2 /z2 {Discounted 50%%%% if you call now![n][n](888) 888-8888}
goto:eof

:frm5
call :makelist
echo( & echo after preparing the file temp.txt, the batch code:
echo call %prg% left /a70 /o2e:mp3. /b1e 177 /i1 /m4 /w+4 temp.txt
call %prg% left /a70 /o2e:mp3. /b1e 177 /i1 /m4 /w+4 temp.txt
goto:eof

:frm6
echo( & echo batch code (quoted):
echo "echo  _____  [n]^|     ^| [n]^|     ^| [n]^|_____^| >temp.txt"
echo "call %prg% left /ae0 /b87 124:179r /i1 /d3 /r4 /z1 temp.txt"
echo  _____  [n]^|     ^| [n]^|     ^| [n]^|_____^| >temp.txt
call %prg% left /ae0 /b87 124:179r /i1 /d3 /r4 /z1 temp.txt
goto:eof

:frm7
echo( & echo code entered from command-line:
echo %prg:.bat=% /a1a /b4f 176 /o1e /w25 /h8 /x197
call %prg% /a1a /b4f 176 /o1e /w25 /h8 /x197
goto:eof

:frm8
echo( & echo batch code:
echo call %prg% /af0 /b3c 177 /i4 /w+20 /y2 /z2 {www.Rent-A-Billboard[n][n]~ or ~[n][n](987) 654-3210}
call %prg% /af0 /b3c 177 /i4 /w+20 /y2 /z2 {www.Rent-A-Billboard[n][n]~ or ~[n][n](987) 654-3210}
goto:eof

:frm9
setlocal DisableDelayedExpansion
echo( & echo code entered from command-line (quoted):
echo "echo ^<^|^>>temp.txt"
echo "%prg:.bat=% left /a1b /bbc 178 /i6 /d5 /r8 temp.txt" & echo(
echo ^<^|^>>temp.txt
call %prg% left /a1b /bbc 178 /i6 /d5 /r8 temp.txt
endlocal & goto:eof

:frm10
setlocal DisableDelayedExpansion
echo( & echo batch code (quoted):
echo "echo ^|__>temp.txt"
echo "call %prg% left /a2b /b6b 177 /i12 /d5 /r7 /w-2 temp.txt" & echo(
echo ...or from the command-line:
echo ^|__>temp.txt
echo "%prg% left /a2b /b6b 177 /i12 /d5 /r7 /w-2 {^|__" & echo(
call %prg% left /a2b /b6b 177 /i12 /d5 /r7 /w-2 temp.txt
endlocal & goto:eof

:frm11
setlocal DisableDelayedExpansion
echo( & echo from the command-line:
echo %prg% /a46 /b3f /e9e /i1 /h15 /w42 /x178
echo ^|__>temp.txt
call %prg% /a46 /b3f /e9e /i1 /h15 /w42 /x178
endlocal & goto:eof

:frm12
echo( & echo batch code (quoted):
echo ">"temp.txt" (For /F "tokens=*" %%%%a In ("^>^>^> ^| ^& ^<^<^<^") Do echo %%%%a)"
echo "call %prg% /a4f /b8 /i4 /w+6 /y1 /z1 temp.txt"
>"temp.txt" (For /F "tokens=*" %%a In (">>> | & <<<") Do echo %%a)
call %prg% /a4f /b8 /i4 /w+6 /y1 /z1 temp.txt
goto:eof

:frm13
call :maketext
echo( & echo after preparing the file temp.txt, the batch code:
echo call %prg% left /a0b /k13 /i2 /m3 /w+3 /y1 /z1 temp.txt
call %prg% left /a0b /k13 /i2 /m3 /w+3 /y1 /z1 temp.txt
goto:eof

:frm14
echo( & echo batch code:
echo call %prg% /a4c /L4e /i3 /w24 /h9 /x197
call %prg% /a4c /L4e /i3 /w24 /h9 /x197
goto:eof

:frm15
echo( & echo batch code:
echo call %prg% /af0 /ba2 179:178R /i8 /y2 /z2 /w+12 {4.5 Acres For Sale[n][n]Next Exit}
call %prg% /af0 /ba2 179:178R /i8 /y2 /z2 /w+12 {4.5 Acres For Sale[n][n]Next Exit}
goto:eof

:frm16
echo( & echo batch code (quoted):
echo ">"temp.txt" (For /F "tokens=*" %%%%a In ("____[n]^|___") Do echo %%%%a)"
echo "call %prg% left /a4e /b3f 177 /i7 /d3 /r8 /w-3 /z1 temp.txt"
>"temp.txt" (For /F "tokens=*" %%a In ("____[n]|___") Do echo %%a)
call %prg% left /a4e /b3f 177 /i7 /d3 /r8 /w-3 /z1 temp.txt
goto:eof

:frm17
echo( & echo batch code:
echo Set "str=        Main Menu[n][n]1.  Browse[n][n]2.  Search[n][n]"
echo Set "str=%%str%%3.  Maintenance[n][n]4.  View Documentation[n][n]5.  Quit"
echo call %prg% left /a2f /k6e /i4 /m4 /w+4 /y1 /z1 {%%str%%}
Set "str=        Main Menu[n][n]1.  Browse[n][n]2.  Search[n][n]"
Set "str=%str%3.  Maintenance[n][n]4.  View Documentation[n][n]5.  Quit"
call %prg% left /a2f /k6e /i4 /m4 /w+4 /y1 /z1 {%str%}
goto:eof

:frm18
echo( & echo batch code:
echo Set "str=        Main Menu[n][n]1.  Browse[n][n]2.  Search[n][n]"
echo Set "str=%%str%%3.  Maintenance[n][n]4.  View Documentation[n][n]5.  Quit"
echo call %prg% left /a1e /b0a 178:177r /i4 /m4 /w+4 /y1 /z1 {%%str%%}
call %prg% left /a1e /b0a 178:177r /i4 /m4 /w+4 /y1 /z1 {%str%}
goto:eof

:frm19
echo( & echo batch code:
echo %prg% /af2 /b5d 178:177RR /i1 /w+10 /y2 /z2 {Welcome[n][n]to The Event}
call %prg% /af2 /b5d 178:177RR /i1 /w+10 /y2 /z2 {Welcome[n][n]to The Event}
goto:eof

:frm20
echo( & echo batch code:
echo %prg% /af2 /b4c 178:177RL /e44 /i4 /w+10 /y2 /z2 {Welcome[n][n]to The Event}
call %prg% /af2 /b4c 178:177RL /e44 /i4 /w+10 /y2 /z2 {Welcome[n][n]to The Event}
goto:eof

:frm21
echo( & echo batch code (quoted):
echo  ____ [n]^|    ^|[n]^|____^|>temp.txt
echo "echo  ____ [n]^|    ^|[n]^|____^|>temp.txt"
echo "call %prg% left /a0e /bce 197 /z1 /d3 /r3 temp.txt"
call %prg% left /a0e /bce 197 /z1 /d3 /r3 temp.txt
goto:eof

::grids

:frm22
echo to show frames in a grid, use this /g notation  /g##:##:ab
echo which is /g[# of frames across]:[# of frames down]:[optional border color codes]
echo( & echo code entered from command-line:
echo %prg:.bat=% /a0e /b0e /g:4:4:ce /h1 /w4 /c197
call %prg% /a0e /b0e /g:4:4:ce /h1 /w4 /c197
goto:eof

:frm23
echo( & echo code entered from command-line:
echo %prg:.bat=% /a3b /b0f /g16:6:87 /i1 /h1 /w2 /x177
call %prg% /a3b /b0f /g16:6:87 /i1 /h1 /w2 /x177
goto:eof

:frm24
echo( & echo code entered from command-line:
echo %prg:.bat=% /af1 /b2e /i1 /g4:1:a /w9 /h4 /x178
call %prg% /af1 /b2e /i1 /g4:1:a /w9 /h4 /x178
goto:eof

:frm25
echo( & echo code entered from command-line:
echo %prg:.bat=% /aa9 /b1e /g24:1:6 /w1 /h1 /x176
call %prg% /aa9 /b1e /g24:1:6 /w1 /h1 /x176
goto:eof

:frm26
echo( & echo code entered from command-line:
echo %prg:.bat=% /a0 /b2e /g1:1:2e /i6 /w12 /h5
call %prg% /a0 /b2e /g1:1:2e /i6 /w12 /h5
goto:eof

:frm27
echo( & echo code entered from command-line:
echo %prg:.bat=% /a02 /K07-- /i1 /g2:2:07 /o0b:207 /x209 /w8 /h4
echo( & Echo "/K07--" interpreted:
echo    split-line border
echo    white font on black
echo    omit horizontal border lines, top and bottom & Echo(
call %prg% /a02 /K07-- /i1 /g2:2:07 /o0b:207 /x209 /w8 /h4
goto:eof

:frm28
echo( & echo code entered from command-line:
echo %prg:.bat=% /a0 /b07 /i1 /g3:3:07 /w7 /h3
echo( & echo grid.bat is written to display this grid of frames.
echo To save your output in a batch file, enter a file name
echo with the /f code to name your file, i.e., /fMyFile
call %prg% /a0 /b07 /i1 /g3:3:07 /w7 /h3
goto:eof

:frm29
echo( & echo code entered from command-line:
echo %prg:.bat=% /ae3 /b7a /i1 /g3:3:e4 /of2:209 /w8 /h4 /fmygrid /x207
echo( & echo the output file is named mygrid.bat & echo(
Call %prg% /ae3 /b7a /i1 /g3:3:e4 /of2:209 /w8 /h4 /fmygrid /x207
goto:eof

:maketext
 >"temp.txt" (
 echo The Old Sea-dog at the Admiral Benbow
 echo(
 echo(
 echo SQUIRE TRELAWNEY, Dr. Livesey, and the rest of these gentlemen having
 echo asked me to write down the whole particulars about Treasure Island,
 echo from the beginning to the end, keeping nothing back but the bearings
 echo of the island, and that only because there is still treasure not yet
 echo lifted, I take up my pen in the year of grace 17__ and go back to the
 echo time when my father kept the Admiral Benbow inn and the brown old seaman
 echo with the sabre cut first took up his lodging under our roof.
 echo(
 echo I remember him as if it were yesterday...
 echo(
 echo       From Treasure Island by Robert Louis Stevenson (1883^)
 )
 Goto:eof

:makelist
 setlocal EnableDelayedExpansion
 >"temp.txt" (
 set "str= 1  1919  piano     102nd Regiment March.mid" & echo !str!
 set "str= 2  1918  piano     11th Street Rag.mid" & echo !str!
 set "str= 3  1915  piano     12th Street Rag (1914) (1).mid" & echo !str!
 set "str= 4  1915  piano     12th Street Rag (1914).mid" & echo !str!
 set "str= 5  1915  novelty   12th Street Rag (1914).mp3" & echo !str!
 set "str= 6  1915  piano     12th Street Rag (E. Bowman).mid" & echo !str!
 set "str= 7  1915            12th Street Rag (E. Bowman).mp3" & echo !str!
 set "str= 8  1915  piano     12th Street Rag.mp3" & echo !str!
 set "str= 9  1913  piano     1915 Rag.mid" & echo !str!
 set "str=10  1913  piano     38th St. Rag.mid" & echo !str!
 set "str=11  1914  piano     A Little Bit Of Heaven (Irish Song).mid" & echo !str!
 set "str=12  1914            A Little Bit Of Heaven (Irish Song).mp3" & echo !str!
 set "str=13  1914  piano     A Little Bit Of Heaven (Shure They Call It Ireland).mid" & echo !str!
 set "str=14  1918  piano     A Little Bit Of Sunshine.mid" & echo !str!
 set "str=15  1914  piano     A Little More Pepper.mid" & echo !str!
 set "str=16  1913  piano     A Mid-October Afternoon (Reverie).mid" & echo !str!
 set "str=17  1914  piano     A Night In Dixieland.mid" & echo !str!
 set "str=18  1917  piano     A Perfect Day (1917).mid" & echo !str!
 set "str=19  1917  piano     A Perfect Day Waltz.mid" & echo !str!
 set "str=20  1919  piano     A Pretty Girl Is Like A Melody (1919).mid" & echo !str!
 set "str=21  1919            A Pretty Girl Is Like A Melody (1919).mp3" & echo !str!
 set "str=22  1910            A Quaker Girl Waltz.mid" & echo !str!
 set "str=23  1915  piano     A Ragtime War.mid" & echo !str!
 set "str=24  1913  piano     A Real Slow Drag.mid" & echo !str!
 )
 endlocal & Goto:eof

:makeTxt
 setlocal
 Set "lineCount=12"

 >"temp.txt" (
    For /L %%i In (1,1,%lineCount%) Do (
       echo Line %%i of a %lineCount%-line file
 ))
 endlocal & exit /b


: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

Last edited by Jer on 22 May 2016 10:23, edited 9 times in total.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#5 Post by Jer » 03 May 2016 20:34

There are a few revisions, added grid features, and a 25th sample added to
samples.bat. Enter 'samples 25' to see the new grid option of alternate colors and fill codes.

This should about do it...I can't imagine packing anything more into the mountain of code.
Re-copy all the code (part 1, part 2, samples.bat)
Jer

edit: discovered that user could enter the tool's filename for an output file. Fixed that on 5/30
after an initial 5/30 post. This involves only part 1 of the batch file posted.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#6 Post by Jer » 09 May 2016 21:33

Refer to the top of this thread for added features as of 5/9/2016.
Other revisions in the code were done to try to make the tool unbreakable
and user-friendly.

I have no plans for adding more features; I used all the letters
of the alphabet except J, as entry codes, and I think enough is enough :)

Enjoy the frame maker tool that works with ColorShow.exe and let me know if anything breaks
when directions were followed.
Jerry

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#7 Post by foxidrive » 10 May 2016 02:44

Good stuff jer!

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#8 Post by Jer » 21 May 2016 00:39

The tool and samples.bat have been updated as of 5/20/2016. You can now choose any of the printable
ascii characters as fillers. Added options to show only vertical portions of borders.
gridMaker function is more complex now to neatly format and optimize the output batch file for ColorShow.
I hope nothing breaks.

sambul35
Posts: 192
Joined: 18 Jan 2012 10:13

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#9 Post by sambul35 » 23 May 2016 07:43

@Jer

Thanks for the tool! To encourage prospective users, would you care to post some pictures showing how exactly your tool enhances ColorShow.exe?

It may help to explain in a few words why it takes so much code to accomplish that, and if certain code sections reuse were possible instead. Just curious... :wink:

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#10 Post by Jer » 27 May 2016 16:47

Thanks for your comment sambul35.

The tool enhances ColorShow by creating a uniform-width colored background and offers
a front end tool to ColorShow to utilize all the features in the tool: output indentation, text margins,
line-borders, character-filled borders, text entry from the command-line or reference to source text file.

There is so much code in part because lots of checks are done to verify that the user input
conforms to what is expected. If the user entered "/ae4/b3d" I saw that it would crash
the program, so I make the efforts to ensure that all entered "/" have a leading space. Also entries
are checked and limited so the output stays within boundaries and doesn't get unrealistically large.
Framed text can't be wider than 150 characters and 50 lines, and I felt those limits were reasonable.

There are different functions of the tool, single-frame making, and separately grid making, a color chart
function to show available colors, the display of an asccii table.

For tool examples, run samples.bat.

I may not be finished yet. Ascii character #127 does not display by itself, but it does if you enter
it like this: colorshow /4e 255 127

I am seeing if I can add special handling of #127 (that means more code!) and am now testing this
in the gridMaker function.

I was going to post an image but I don't know how to use the Img function.

edited 6/3/2016 - re: ascii code #127-it appears that "255 127" is required with consolas font, while
"colorshow 127" displays #127 correctly if the font is raster. In further development, I will use "255 127"
to display the "toolshed" character or whatever it is that code #127 represents, and this will add a variation
in the grid outer border (border surrounding all the frames) with 3 columns each in the border verticals.
Last edited by Jer on 03 Jun 2016 21:29, edited 1 time in total.

sambul35
Posts: 192
Joined: 18 Jan 2012 10:13

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#11 Post by sambul35 » 28 May 2016 19:22

What I mean, your above batch must be a laborious undertaking. And you obviously want others to use it given this thread. In this case nothing works better than pictures to attract new users. Try sites like PostImage to upload your screenshots, and post generated by your pictures hosting website links here. That's were Img feature of Post Reply text field may come handy, unless your PostImage links already have [Img] attribute.

An example of check function reuse is given here. Reusable functions may help greatly to shorten a batch code.

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#12 Post by Jer » 29 May 2016 21:35

Edit. sorry, I need more detailed instructions on how to use PostImage so that the images
appear in this post, and not just show a link to take you to another window.

[moved text to my next post where images are included]
Last edited by Jer on 30 May 2016 10:54, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#13 Post by foxidrive » 30 May 2016 00:05

This style is what should work, but remove the periods inside the []

[.img.]http://blah.blah.com/image.jpg[./img.]

Jer
Posts: 177
Joined: 23 Nov 2014 17:13
Location: California USA

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#14 Post by Jer » 30 May 2016 11:01

As I read through the printed hard-copy of my very large batch file,
I will look for ways to reuse code in functions.

Tool documentation is built in and can be browsed by entering frametool ?

The tool lets you save your frame or a grid of frames in a batch file that produces
the same display. One of the features of this tool is that ColorShow.exe is executed
one time, so if you have a newer (faster) computer, you see the frame "almost" pop up.

Here are some frame examples of this tool.

Image

Image

Image

Image

Image

edit: 2nd image listed. changed "/240" to "240"
edit: 5th image. "/g:6..." changed to "/g6", colon not required
Last edited by Jer on 01 Jun 2016 10:39, edited 4 times in total.

sambul35
Posts: 192
Joined: 18 Jan 2012 10:13

Re: Batch-VBScript Hybrid - Frame Maker for ColorShow.exe

#15 Post by sambul35 » 30 May 2016 13:06

Jer wrote:As I read through the printed hard-copy of my very large batch file,
I will look for ways to reuse code in functions.


Nice pics! :D

Here's another version of the mentioned verification function. You can add your own verification sections with ) else if ( statements for each task type, or better yet try to maximize use of Call feature to keep verification code unified to the minimum size possible, and leave some Call arguments empty if not applicable, and other arguments adjusted.

Post Reply