If you run this, the cmd box will show up, and will ask you "Do you like grapes? If you type in a response and press enter or return , it will say "You said: [Whatever you said here]". Now let's look at the code. We understand sort of the first three lines. You are probably wondering "what the heck?
Well, the word "set" basically says to the computer "we are creating a variable". In this case, we are making a "p" variable. I do not know what this stands for. The "grapes" is the variable. Maybe you can change it to "x" or "y" or something simpler later on, but for now, keep it as grapes. This whole line creates a sort of question, which you need to type something in and press enter to continue. Whatever you type in is the data stored in the variable. That means, if you type in "yes", that would mean that the variable grapes is equal to "yes".
Oh yeah, and don't forget the equal sign. Now on to line 5. Pretty simple, except for the last part. That's because, ladies and gentlemen, putting a variable in between two percent signs basically puts the data there. If you typed in "yes" for the fourth line, it would say "You said: yes". That's alot of learning. It might be hard to understand this, but it's a whole different story to make this. I'm sorry, I'm doing the best I can :. You have made it this far in the tutorial!
You are awesome! If you didn't make it this far, you stink. But since they didn't make it this far, they wouldn't see this message, therefore it's okay to say. We learned in the last step how to create a question I guess that's what you call it in batch code.
Now we have to make the computer do something. Forex, if you asked someone "What's two plus two? Now how would we make that in batch file code? Basically, it will go like this: The question is asked "What is two plus two? If the user types in 4, say "Correct! If the user says anything else, say "Incorrect! Now, let's make that in code.
Before you bulge your eyes out, let me try to explain. Hopefully you understand lines A brief refresher on 4, whatever the user types in, is basically stored in the variable "answer". Line 5 Here's where it get's tricky. This is because the single equal sign is used for many other purposes. That's what it's saying.
Now in the parentheses, you understand the "echo Correct! But exit? It was so simple, I forgot to explain. Basically, this will just exit out of Cmd as a whole. This is saying if the answer is not 4, then do whatever is in the parentheses. TIP: Always remember, when doing else statements, put a space between the "else" and the opening parentheses.
The first one is fine. I made a batch game wth some code like u, but when i opened the file, it open and suddenly dissapear in 1 second. Wht is that error? Reply 16 days ago. Question 7 months ago. Why is there an issue? Tip 11 months ago. You can delete and start files from a batch file, so be careful are you put in there.
I made an Explorer Restarer. Since learning about batch files, I started to make viruses and test them myself. It was so fun. But I wanted to learn more, and with your article, I got even better at making batch scripts. Feel free to ask me any questions. I know this was worded weirdly, but I assure you this was the best I could do.
I have a problem explaining things, and I'm much better at showing things visually. Reply 1 year ago. Question 3 years ago. Answer 2 years ago. Reply 2 years ago. Reply 4 years ago. What is a batch file? Let's get started! Next, you are going to want to open up three things: Notepad Cmd or Command Prompt if you want to be all fancy and stuff Windows Explorer you know, that file explorer thing?
It's called different things Now you are ready to start coding! Your First Few Commands The first command you are going to learn is: echo off Type this text in the notepad. Name your file whatever you want, but include ". With these three commands, we can make a basic book I don't know what to call it First, I will give an example: echo off echo Hello. You know the drill. Save it, and run the code. After doing this, go back into notepad, and try making one of these your self.
Next, we will move on to three more commands. It does what many people assume it does: clear the screen. If you are more comfortable with Microsoft Windows, you can use any text editor such as Notepad or WordPad to create your batch files. As long as the file extension ends with. In the example below, we use the Windows Notepad to create a batch file. See our what commands are available in a batch file page for commands that can be added to a batch file.
New versions of Windows or computers running a bit version of Windows no longer support the edit command, which means these steps no longer work. Use the above steps if you are running the latest version of Windows. If you want to add more lines to this batch file, type edit test. If this the case, you would either need to obtain the edit.
0コメント