CmdInStyle - working on a style/color function script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

CmdInStyle - working on a style/color function script

#1 Post by mirrormirror » 12 Feb 2016 22:27

I'm working on a script to display basic messages in colored "styles" in the command console. It relies on the utils provided by Aacini ( viewtopic.php?f=3&t=3428 ).
The code is not "Pretty"
It is not "polished"
It is not "optimized"
It is not 100% complete... (and I don't know when I will have time to finish it)
But is currently functional - so I thought I'd offer it to anyone who might be interested in this sort of thing.
Here are examples of what it does (notice an "INIT" is run first):
Image
You can see that different STYLES (info1, warn1, block1, stop1) are applied to the same text. In the last example a "PAUSE" command is embedded right into the style.
A 2nd mode I call "FlexStyles" can also be used - originally meant for hierarchical display - for example this code produces the result below:

Code: Select all

%fStyle_01Begin%
   %FlexStyle% l1 "JOB xxxxxxx Completion Statistics"
   %FlexStyle% l2 Error Summary
   %FlexStyle% l3 2 copy failures
   %FlexStyle% l4 \\source\folder1\folder2\file1.xxx
   %FlexStyle% l4 \\source\folder1\folder2\file2.xxx
   %FlexStyle% line4
   %FlexStyle% l2 Total elapsed time: 00:00:00
   %FlexStyle% l2 Total files processed: x,xxx
%fStyle_01End%

Image
Or you can display the same text using an alternate style:

Code: Select all

%fStyle_02Begin%
   %FlexStyle% l1 "JOB xxxxxxx Completion Statistics"
   %FlexStyle% l2 Error Summary
   %FlexStyle% l3 2 copy failures
   %FlexStyle% l4 \\source\folder1\folder2\file1.xxx
   %FlexStyle% l4 \\source\folder1\folder2\file2.xxx
   %FlexStyle% line4
   %FlexStyle% l2 Total elapsed time: 00:00:00
   %FlexStyle% l2 Total files processed: x,xxx
%fStyle_02End%

Image
A bit more info below.

Code: Select all

Purpose:
   This script allows the creation of a collection of "styles" which can be called from other scripts.
   The attempt was made to allow for minimal syntax requirements while adding color functionality
   There are a few pre-defined "styles" already included but it is meant for user customization.
   Each "style" is defined by a set of properties (colors, text elements, newline entry, etc.).
   It has functionality to allow running of external commands both PRE-style display...
      and POST style display.
         For example, you could insert a "pause" command after a "Critical_ERROR" style...
         OR GRAB a TIMESTAMP before starting a process, etc.
      The number of pre/post run commands is flexible and can be increased as needed with...
         the simple addition of a property like this:   "PreCMD_03=GetTimeStamp.cmd xxxx"
      Properties (including pre/post run commands) can be set as GLOBAL defaults and/or ...
         on a per-style basis.
   The "HELP" functionality can enumerate all defined styles, their command-line usage, ...
      and display them as they would appear on-screen

Help screen:
Image
My batch coding skills are not great so if you guys think this concept is useful, I would welcome addition features, special character handling, code optimization, etc. There is still leftover and debug code all through the script so please don't mind my mess :)
I've uploaded it here: https://storage-eu.gmx.com/qx/gmx_com_e ... 3Aexplorer
Password is DOSTIPS
Remember, will also need this (see link at beginning of post):

Code: Select all

DEPENDENCIES:
   Credit to Antonio Perez Ayala for these utilities
      Colorshow.exe
      Textcolor.exe
      Cursorpos.exe

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: CmdInStyle - working on a style/color function script

#2 Post by mirrormirror » 13 Feb 2016 20:04

FYI: I updated the description and uploaded the file - see original post.

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

Re: CmdInStyle - working on a style/color function script

#3 Post by foxidrive » 14 Feb 2016 02:25

I like the look of the screenshots, nice work.

Post Reply