Objectbatch is an object-oriented extension of the Windows batchfile language, including classes and instances, methods and attributes, inheritance, encapsulation, polymorphism and object composition.
Simple use of a class instance:
::instantiate new object obj of type MyClass
call new MyClass obj construct
::calling method myMethod of instance obj
call # obj myMethod
::reading obj attribute myAttr
echo !%obj%.myAttr!
::writing obj attribute myAttr
set %obj%.myAttr=1
Simple class definition:
::boilerplate
call class %*
%class%
::this is the constructor, adding one custom attribute attr
:public-construct
call super %*
set %self%.attr=0
exit /b
To get a copy of this repository, simply open up git bash in an empty folder and use the command:
$ git clone https://github.com/rbaltrusch/objectbatch
To use objectbatch anywhere, add the objectbatch folder to your Windows PATH.
For more information on the various object-oriented features available, please have a look at the examples and the wiki.
An example object-oriented batchfile repository can be found here.
- Changed object state within a local scope (
setlocal
) can only persist by usingsave.bat
. - Batchfile bug: it seems that instantiating many objects at once causes older objects to vanish. Circumvent this issue by serialising with
save.bat
.
Any contributions, such as additional features, bugfixes, or documentation are much appreciated. Contribution guidelines are specified in CONTRIBUTING.md.
This repository is open-source software available under the MIT license.
Please raise an issue for code changes. To reach out, please send an email to richard@baltrusch.net.