OOP in Batch

Hi, I’m Nguyen Phu Minh, creator and lead developer of the FreakC Programming Language. Since Batch does not have object-oriented programming, so today I’m sharing my attempt in “faking” OOP in Batch.

Creating a structure

First, I will crea…


This content originally appeared on DEV Community and was authored by DEV Community

Hi, I'm Nguyen Phu Minh, creator and lead developer of the FreakC Programming Language. Since Batch does not have object-oriented programming, so today I'm sharing my attempt in "faking" OOP in Batch.

Creating a structure

First, I will create a file called "Dog.bat":

:: Creating properties
set %~1.age=%~2
set %~2.weight=%~3
:: Creating a child method
(
echo echo %%~1!
)>%~1.say.bat

Then, I will create a main file which we run our code on:

:: Create an object
call Dog "Mary" "3" "4kg"
:: Prints out "age" property of "Mary", which is "3"
echo Age: %Mary.age%
:: Call "Mary.say" with argument "Woof", which prints out "Woof"
call Mary.say "Woof"

That's it! Simple, right? Please comment if you've a better solution.


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2021-05-08T12:47:48+00:00) OOP in Batch. Retrieved from https://www.scien.cx/2021/05/08/oop-in-batch/

MLA
" » OOP in Batch." DEV Community | Sciencx - Saturday May 8, 2021, https://www.scien.cx/2021/05/08/oop-in-batch/
HARVARD
DEV Community | Sciencx Saturday May 8, 2021 » OOP in Batch., viewed ,<https://www.scien.cx/2021/05/08/oop-in-batch/>
VANCOUVER
DEV Community | Sciencx - » OOP in Batch. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/08/oop-in-batch/
CHICAGO
" » OOP in Batch." DEV Community | Sciencx - Accessed . https://www.scien.cx/2021/05/08/oop-in-batch/
IEEE
" » OOP in Batch." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2021/05/08/oop-in-batch/. [Accessed: ]
rf:citation
» OOP in Batch | DEV Community | Sciencx | https://www.scien.cx/2021/05/08/oop-in-batch/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.