9/STOP, LOOK, AND LISTEN
Numeric Variables
Do you have a program currently in memory? If you do, add one more line to finish it. For instance:
100 END
Whenever the Micro Color BASIC encounters the command END in a program, it immediately stops. Of course, if there are no other instructions at the end of a program, it will stop anyway; but good programming practices dictate that you should always end your program with END.
Sometimes, you may want to put the END command in the middle of a program, especially if you're using "subroutines" (more on those later). Here's an example of how you might want to use END:
10 PRINT "THIS IS THE TEST FOR 'END'"
20 PRINT "THIS LINE WILL BE PRINTED"
30 END
40 PRINT "BUT THIS LINE WON'T"
50 END
Now RUN it. Your TV will display this:
THIS IS THE TEST FOR 'END'
THIS LINE WILL BE PRINT
OK
There Has To Be An Easier Way...
Notice that the Control Command key sequence of:
[CONTROL][:]
will also display the END command.
The STOP Command
A close cousin of END is the STOP command.
STOP also halts program execution. However, it is generally used inside the program instead of at the end. The sample program used above would be a more "correct" program if it used STOP like this:
10 PRINT "THIS IS THE TEST FOR 'END'"
20 PRINT "THIS LINE WILL BE PRINTED"
30 STOP
40 PRINT "BUT THIS LINE WON'T"
50 END
When you RUN the program with line 30 changed to STOP, the results are almost the same:
THIS IS THE TEST FOR 'END'
THIS LINE WILL BE PRINTED
BREAK IN 30
OK
This points out the main difference between STOP and END. With END Micro Color BASIC assumes the program has ended. With STOP, the program has simply been interrupted.
There Has To Be An Easier Way...
Instead of typing in the command STOP everytime you want to use it, simply press the key-combination of:
[CONTROL][-]
and STOP will appear on the Screen.
The [BREAK] Key
Pressing [BREAK] during program execution is another way of stopping program execution. While STOP halts program execution "automatically", pressing [BREAK] halts it "manually".
When you press [BREAK], a message similar to the following is displayed"
BREAK IN 30
OK
The CONT Command
Once a program has been interrupted by STOP or END, or by pressing [BREAK], you can continue program execution with the CONT ("continue") command.
CONT is handy to use in the Immediate Mode when you're trying to find out what's wrong with ("debug") a program.
For instance, you already know what will happen if you execute the following program:
10 PRINT "THIS IS THE TEST FOR 'END'"
20 PRINT "THIS LINE WILL BE PRINTED"
30 STOP
40 PRINT "BUT THIS LINE WON'T"
50 END
The TV will display:
THIS IS THE TEST FOR 'END'
THIS LINE WILL BE PRINTED
BREAK IN 30
OK
At this point, type:
CONT [ENTER]
and the rest of the program will be executed:
BUT THIS LINE WON'T
OK
There Has To Be An Easier Way...
To use CONT without typing it in, press the key-combination of:
[CONTROL][2]
and then press [ENTER].
The CLS Command
Are you tired of pressing RESET to clear the Screen? Why not let the MC-10 clear its own Screen. To do this, use the CLS ("Clear Screen") command.
CLS (color-code) color-code specifies the background color of the TV SCREEN and is a numeric expression between 0 and 8. color-code is optional, if omitted, 1 is used. Note: The ( ) are optional. |
CLS will clear the Screen, while leaving the current contents of memory intact. If you simply type in CLS [ENTER], Micro Color BASIC will clear the Screen with the normal, default color (green).
If you include a number between 0-8 after the command (see Table 3), the Screen will be cleared in the specified color.
For instance, if you type CLS 8 [ENTER] (remember that the parentheses are not required), the Screen will turn orange. Now you know for sure that it's a "color computer".
Why is there a green stripe across the top? Because the MC-10 cannot display regular characters on anything but a green background. (Graphics Characters are a different story however.)
Note that if color-code is a number greater than 8, the message MICROSOFT or a ?FC ERROR will appear and the Screen will turn green.
CLS is a useful command to use at the beginning of a program when you want the program listing (or any other display) to be erased.
Code |
For This Color |
0 |
black |
1 |
green |
2 |
yellow |
3 |
blue |
4 |
red |
5 |
buff |
6 |
cyan |
7 |
magenta |
8 |
orange |
Table 3 |
There Has To Be An Easier Way...
To enter the CLS command the easy way, press the key-combination of:
[CONTROL][8]
You can then either type in a color code and press [ENTER] or just press [ENTER] for a green Screen.
Add CLS to a program by typing:
5 CLS [ENTER]
When you list the program, the TV will display:
5 CLS
10 PRINT "THIS IS MY FIRST MC-10 PROGRAM"
20 PRINT "THIS IS THE SECOND LINE"
50 END
When you RUN it this time, the Screen will automatically clear.
The SOUND Command
Since a TV has sound capabilities, and since the MC-10 was designed to be connected to it, your Computer can also generate audio output. To produce a sound, use the Micro Color BASIC SOUND command.
SOUND tone, duration tone specifies the sound you wish to generate and is a numeric expression between 1 and 255. duration specifies the length of time tone is to be generated and is a numeric expression between 1 and 255. 1 is approximately 7.5/100 of a second. Both tone and duration must be specified. |
Before using SOUND, be sure the volume is set to normal listening range.
Type in this:
SOUND 1,100 [ENTER]
When you press [ENTER]. the Computer's lowest tone will be produced for 7.5 seconds. Want to try the highest tone? Try this:
SOUND 255,100 [ENTER]
That, as they say, is the other end of the sound spectrum.
Try some other numbers, but don't exceed the 1-255 range for either tone or duration or you'll get an ?FC ERROR. And don't forget, both tone and duration must be included or a ?SN ERROR will occur.
The REM Statement
Are you ready for a different type of program? Type in this:
10 REM THIS IS MY 2ND PROGRAM
20 REM IT USES "REM"
LIST the program and check for typing errors-especially in the spelling of REM.
Now RUN the program. Nothing happened, right? No error messages appeared and the OK prompt returned.
REM message message can be any information you want displayed. |
The REM ("remark") statement allows you to include extraneous information in a program line without generating an error message. What happens is that any time Micro Color BASIC encounters a REM statement, it simply ignores everything that comes after it.
You'll find REM a handy way to include explanatory messages within programs or program lines. Note that REM can be used in the middle of a program line as long as it is preceded by a colon (:). The following are all valid uses of REM:
10 REM ARITHMETIC PROGRAM
20 PRINT 10 + 5 :REM ADDITION
30 PRINT 10 - 5 :REM SUBTRACTION
40 PRINT 10 / 5 :REM DIVISION
50 PRINT 10 * 5 :REM MULTIPLY
60 END
|
|