You are not logged in.

#1 23 Dec 2019 14:41

carlos
Member
From: Chile
Registered: 04 Nov 2008
Posts: 251
Website

Enhanced Batch

Hello.
I was waiting to publish this later, but I think is better do it now. Is for present to all the users of this forum the project "Enhanced Batch" (abbreviated in this post as EB), developed with my friend Jason Hood.

Is a tool wich purpose is "Improve the functionality of your classic Windows batch files".

This tools takes control of cmd.exe adding features and new "internal" commands.

For example have you wanted this next:?
- Easily print emojis (with Windows Terminal)
- Know the line number in which for /f loop is processing
- Have a infinite loop that allow easily go out of it?
- Access to a parameter index greather than 9 whitout need of use shift?
- More flexible range generation of number than for /L ?
- No slow goto ?

With EB you can do.

At this time, after round one year of development, the code

Currently have no release, because we continue working on add new features, but you can compile the current code using TDM GCC MinGW-w64 5.1.0-2 with the command:

mingw32-make

The code is available in:

https://github.com/carlos-montiers/enhancedbatch

One you have the dlls you need run this command:

Rundll32 "%~dp0enhancedbatch_%processor_architecture%" Load
If Not Defined @enhancedbatch (
Echo Load Failed
Pause
Exit
)

And that is all. Now you have access to new features of batch and EB filters and EB commands called "extensions".

Here a give you some little examples of the thing you can do with a "new batch syntax" (EB syntax):

Enable delayed expansion without create a new local environment (setlocal):

set @delayedexpansion=on

Easily encode unicode characters and display it using Windows Terminal:
emojis.cmd

echo star-struck: %U+1F929%

emojis.png

Save a large text in other space rather than environment block, called heap:
heap-example.cmd

Set $myPrivateVar=Okay
:: Looking in the environment block, it will say not defined.
Set $myPrivateVar
:: Looking if is defined in the heap
If Defined $myPrivateVar (
Echo Yep, it is defined in the heap
Echo $myPrivateVar = %$myPrivateVar%
)

prints:

heap-example.cmd:10: Environment variable $myPrivateVar not defined
Yep, it is defined in the heap
$myPrivateVar = Okay

Also you can notice how EB, by default in case of error says the batch filename and the line whre the error was produced, in this case the line 10.
heap-example.png

Apply filter to text variables:

set "$var= oKay "
echo   Default: !$no-var;'undefined'!.
echo     Upper: !$var;upper!.
echo     Lower: !$var;lower!.
echo   Capital: !$var;capital!.
echo    Length: !$var;length!.
echo      Trim: !$var;trim!.
echo     LTrim: !$var;ltrim!.
echo     RTrim: !$var;rtrim!.
echo Trim[ oy]: !$var;trim[ oy]!.
echo LTrim[ o]: !$var;ltrim[ o]!.
echo RTrim[ y]: !$var;rtrim[ y]!.
echo  Trim,Cap: !$var;trim;capital!.

prints:

  Default: undefined.
    Upper:  OKAY .
    Lower:  okay .
  Capital:  Okay .
   Length: 6.
     Trim: oKay.
    LTrim: oKay .
    RTrim:  oKay.
Trim[ oy]: Ka.
LTrim[ o]: Kay .
RTrim[ y]:  oKa.
 Trim,Cap: Okay.

The best way of know the tool is through the demo batch files:
Here I present some slides of the demos:

demo.cmd (this is an animated gif, you need wait a little bit for see each "slide")
eb.gif

demo-image.cmd // display an image using gdi pixels
image.gif

demo-img.cmd // display an image using characters
img.gif

demo-text.cmd
text.png

Any suggestion for this tool is welcome, we continue the development with the hope of release the first version in a few months.
Feature request can be posted here:

https://github.com/carlos-montiers/enhancedbatch/issues

The documentation of the tools is in

https://www.enhancedbatch.com/

(currently not fully updated)

EB is compatible with all cmd.exe released versions since windows 2000 !!

Last edited by carlos (23 Dec 2019 14:48)

Offline

Board footer

Powered by