Today's project is somehow special, the way it allows you to learn how to create a simple IDE for Batch language which is related to Windows' commands. It will shows you good tricks to use
RichTextBox controller tricks too.
As any Windows user, I do use Windows' DOS commands and I did create a lot of .bat applications before.
Honestly, writing batch codes in a Notepad, then saving them as .bat extensions to use them later is a waste of time. That's why I needed to create a simple debugger which contains 1
TextBox (to write the codes) & 1 button (to debug them).
By the time, I developed my own project and it really helped me. Therefore, I want to post my full project here.
Why Should I Create or Use a Project Like This?
Well, let's throw our cards on the table:
- This project will solve the problem of wasting time, in other words, you won't need to write and save your batch codes as a .bat file to execute them later because using this project you can execute the codes directly.
- How can it help me? Good question, as I said before, you won't waste time anymore by saving your code and executing them after. Also, the environment that this project gives to you is pretty much better than the basic Notepad in my opinion.
- The code here is pretty useful - the ways that you will learn about new tricks about
richTextBox controller and other Visual Studio tools.
Using the Code
The code which is used in this project is too easy, the most important part here is 'Debugging the code' part. I created a class library which contains the debugging method.
Debug the code class (class library: Batch compiler project ==> Compiler.cs)
public class Compiler
public static void Debug(string code)
string path = Path.GetTempPath() + "test.bat" ;
code will contain the text which is written in the
path will contain the path where the file will be saved at.
Now let's go back to the main project
Import the reference
Right click on "References", result:
Click on "Add Reference..." then this window will appear:
As you can see, we only have created one project beside our main project. So simply click on OK button to import it. Done!
Import the library and the debug method
After we imported our reference (
Batch_Compiler) we have to use it, add this code:
Then, add this code to create a new variable:
public Batch_Compiler.Compiler Compiler = new Batch_Compiler.Compiler();
Debug (Run the code)
Now let's go to the last part of our project, debugging the code part. All that you have to do is:
- Rename your
richTextBox controller to "
Batch" (just an example)
- Double click on Debugging button, then add this code:
Compiler is the variable which we created from the start
Debug is the method that we imported from
Batch_Compiler class, it is the method that is used to compile the code (save, then execute it)
Batch is our
richTextBox controller that we named "
Now you can build your project.
How to Use the Tool
To use this application as a user, you have to go through these easy steps:
What Can I do Using This Software?
- You can use the software to write your own batch codes.
- You can save them as Batch file or Text file.
- You can debug the batch code directly without the need to save the code into .bat file.
- You can save the batch codes into a .bat file to use it later (use the green button : )
Points of Interest
It is so funny how my friends kept asking for the source code of this project and I kept ignoring them (acting). It will be a good surprise for everyone (I hope), but it is great to see a lot of people who want to learn.
- March 19, 2015: First upload