Introduction: How to Batch for Starters
That is an image of one of the simplest forms of coding there is. Batch. Not too many people know about it, but it (in my opinion) is the best coding language there is. It's about as simple as a DOS interface, and quite similar, too. When you wanted to delete a file in DOS, you would type in something along the lines of:
And it would be gone. The interface then was just a blank screen to type instructions like this into. Today, computers do the same thing, but they've been pre-programmed to interpret dragging a file over the icon for your "Recycling Bin" as the delete command. Underneath the fancy graphics, Batch is at work, operating the computer.
Step 1: Batch Codes
Above is the code that created the batch file. just save it as a .bat, and you have a batch file! Don't code batch in Microsoft Word, it doesn't work. But Notepad, a standard Windows software, does.
1. All files need to start with a line saying @echo off. Try it without to see why.
2. Color changes the text from grey on black to something more exciting. Look up "Batch File Colors" to find codes like 0A (my personal favourite).
3. Mode 1000 makes the window go full screen.
4. Title sets the title of the page. Title Blabaloosh, and that's the name of your page when opened.
5. Goto commands are a bit more complicated. It would make the code go to the matching colon. Example:
DESTROY THE WORLD
the code went from Goto to Blabaloosh, and skipped Destroying the world (Not a real batch command).
6. Echo makes the following text appear.
7. %random% acts as a random number between 1 and 32016. Don't ask me why 32016.
8. Set, Set/a, and Set/p are all complicated commands.
It would read out a text saying 20.
Set/p Text=What's your Name?
Would allow the user to type something, which would then become the variable "Text". What's your name? would come before the space to type.
This would make %Num% be 2. Basically, use this for equations.
9. Choice is easily the most complicated Batch code I know. Well, no, but it's the most complicated Batch code you're ready for. Pay close attention to this. If you're confused, ask me in the comments.
Choice /c PE /n
if %errorlevel% == 1 (
if %errorlevel% == 2 (
P and E are the keys you would press in this instance. Since P is the first listed, pressing P would be
"errorlevel 1". Pressing E is %errorlevel 2%. EXIT is a command I have not yet taught you- I will now.
10. EXIT closes/ends the program.
11. Pause will wait until a key is pressed.
12. Timeout will wait a certain amount of seconds, maximum 1000. Example:
Timeout /T 1
Will wait 1 second.
Timeout /T 1 >NUL
Will wait 1 second, and display no text because of it. you can use >NUL on any code.
One last thing: if a batch script reaches a point of no text, it will end. this can be circumvented by Goto. good luck!