Line Function: Just finished-up creating another Awesome Function that will definitely make your batch programming experience easier. Take this as another step towards getting creative in your CLI–GUI APPROACH In your batch scripts, as now you can create GUI lines with characters in cmd from one point to the other within the cmd console window.
The line function 1.0 is created by Kvc (but, we have used an already existing algorithm). Also fixed few bugs (time limit issue and inefficient output on the console screen). Now the function is properly managed and created to flawlessly display the required line on console screen in almost no time.
GUI LINES WITH CHARACTERS IN CMD – Line Function 1.0
The Line function v.1.0 Uses Bresenham’s algorithm for achieving the goal of creating GUI lines with characters in cmd without flaws on the console. The function calculates all the possible positions of pixels (characters in this case) on the console.
And, then we are printing the specified character in given color on those positions using ‘Batbox’ plugin. Which is responsible for the tremendous speed and response time of the function.
The Line functions 1.0 seem to be working perfectly in all of our tests, but if in any case – it shows a flaw or error. You can comment on it below this post. But, we hope that your comments will be about, how fast and awesome this function is.
USAGE – Using Line Function 1.0 by Kvc
The function simply prints a line of required properties (including starting pt, ending pt, printing character, line color) by simply using ‘Batbox’ plugin as one of its dependencies. which means, that you only need to keep batbox.exe file with this line.bat function file, in the same folder/directory – where your main batch file is residing.
Then you are ready to go. Your program will become tremendously advanced and smaller (simple) and the whole project file’s size will increase only by 5 KBs (some 4.6 KB). This is the advantage of creating functions that you can use them whenever you want in your program.
So now, let’s talk about its usage and output on the CMD console. The following image will help you a little in finding the usage of line function ver.1.0 by kvc, or you can also see this help message by simply typing ‘Line /?’ in your cmd console window.
As you can see that – The usage of this function is very easy and you can also see the Examples provided in the Help Menu. You may or may not – have to specify the character and color of the line, these depend on your requirements.
Features – Line Function 1.0
You can also print line only by specifying only the first 4 parameters, and in this case – this function will take ‘o’ as a default character and ‘07’ as a default color code. The following image may clarify your remaining doubts. So, let’s have a look.
But, you can also print the line using any of your required characters. You either need to specify the character in the 5th parameter or the ASCII code of the character. Which you want to print a line with. And also you can provide the color of the line in the 6th parameter.
Fetch Code of Line – Instead of showing on CMD
If you want code of the line instead of directly printing it on the console. You just need to specify the 7th parameter as a variable, and the code of the resultant line – will be saved into the same -named variable. This code can be executed directly using batbox plugin, Or you can save it in a text file to use it later in any of your batch programs.
Instead of printing using a backslash (/). You can also print the line using any other character or color. For example, as I’ve printed the same line with the same color but this time – I’m using forward slash (\) instead of the backslash (/). And, the output has no effect but only change in the character by which the line will get printed.
From Editor’s Desk
At last, if you really like our work in the field of batch programming – feel free to leave your precious reviews/feedbacks below in the comment field below. We’ll love to see your reactions to our work, Thanks for your time. Till then, as we always say.
HASH Code - For Verification - (SHA-256)
Keep learning, keep sharing….TheBATeam
Be happy, spread happiness…