• 11/11/13 2:11 pm
- 694 views • 0 today
- 2
- 1
- 2
16
Hello! Today I am going to teach you how to code BASIC! I am going to show you the basics.
Languages
Languages are very important to coding. Languages are important because there are many types of coding. Languages take a type of code, and name it. When computers were new to the world, the only language of coding was named, "basic". But for this tutorial, I am going to show you one of the most popular languages, "Batch."
What is BASIC?
BASIC/Batch is a type of language, that is very simple. Whenever you start coding, you want to use notepad. When you open notepad, write this:
@echo off
cls
First time coding?
Make sure that it is the first line of code. As you can see, I wrote, cls below @echo off. "cls" clears the chat.
Next, make your first file. Type :menu below cls, then cls again. After that choose the color of the command prompt. Here is the color key:
0=Black
1=Blue
2=Green
3=Aqua
4=Red
5=Purple
6=Yellow
7=White
8=Gray
9=Light Blue
A=Light Green
B=Light Aqua
C=Light Red
D=Light Purple
E=Light Yellow
F=Bright White
Then combined them. For example, 0e changes the color so the text is yellow and the background is black. Then type cls once again. Now, if you want the program to say something, type, "echo (message).
This is the code we have so far:
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
Files
Files are like a chain, lets say you type, "echo What is 2+2? After that you would have to right a command telling the computer that you are creating a new chain of files! Then if you type the key word, it will take you to a different file. Here is an example. I put the new piece if code in bold.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
The bottom part of the code means that if you do not type anything, or if you don't type 4, it will send you to the file, named wrong. To make a file, type, :filename. Make sure there is no spaces. Here is an example with our code.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
Now we will make a new file name called, correct. So we can make a solution to 2+2. The new piece of coding is in bold.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
:correct
cls
You are correct! Good job...
Whenever you want to end the the program, type pause. If you don't type pause it will automatically close with an error.
If you want to test the code yourself, copy and paste the code below in notepad. Then save it as File.bat
Make sure you put .bat or else it won't be saved as a batch file. Then go to documents and open the batch file.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
echo Type, "retry" to restart.
set /p number=
if %number% == retry goto menu
if not defined hey (
cls
goto wrong
)
:correct
cls
echo You are correct! Good job...
pause
Languages
Languages are very important to coding. Languages are important because there are many types of coding. Languages take a type of code, and name it. When computers were new to the world, the only language of coding was named, "basic". But for this tutorial, I am going to show you one of the most popular languages, "Batch."
What is BASIC?
BASIC/Batch is a type of language, that is very simple. Whenever you start coding, you want to use notepad. When you open notepad, write this:
@echo off
cls
First time coding?
Make sure that it is the first line of code. As you can see, I wrote, cls below @echo off. "cls" clears the chat.
Next, make your first file. Type :menu below cls, then cls again. After that choose the color of the command prompt. Here is the color key:
0=Black
1=Blue
2=Green
3=Aqua
4=Red
5=Purple
6=Yellow
7=White
8=Gray
9=Light Blue
A=Light Green
B=Light Aqua
C=Light Red
D=Light Purple
E=Light Yellow
F=Bright White
Then combined them. For example, 0e changes the color so the text is yellow and the background is black. Then type cls once again. Now, if you want the program to say something, type, "echo (message).
This is the code we have so far:
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
Files
Files are like a chain, lets say you type, "echo What is 2+2? After that you would have to right a command telling the computer that you are creating a new chain of files! Then if you type the key word, it will take you to a different file. Here is an example. I put the new piece if code in bold.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
The bottom part of the code means that if you do not type anything, or if you don't type 4, it will send you to the file, named wrong. To make a file, type, :filename. Make sure there is no spaces. Here is an example with our code.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
Now we will make a new file name called, correct. So we can make a solution to 2+2. The new piece of coding is in bold.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
:correct
cls
You are correct! Good job...
Whenever you want to end the the program, type pause. If you don't type pause it will automatically close with an error.
If you want to test the code yourself, copy and paste the code below in notepad. Then save it as File.bat
Make sure you put .bat or else it won't be saved as a batch file. Then go to documents and open the batch file.
@echo off
cls
:menu
cls
color 0e
cls
echo Hello and welcome! This is my tutorial on how to code!
echo What is 2+2?
set /p number=
if %number% == 4 goto correct
if not defined hey (
cls
goto wrong
)
:wrong
cls
echo I am sorry, but you are incorrect. :(
echo Type, "retry" to restart.
set /p number=
if %number% == retry goto menu
if not defined hey (
cls
goto wrong
)
:correct
cls
echo You are correct! Good job...
pause
2427760
6



Have something to say?