Vtech PreComputer Power Pad Plus User Manual - Page 38

Basic Computer Tutorial

Page 38 highlights

BASIC COMPUTER TUTORIAL EXAMPLE OF A BASIC PROGRAM You and Teresa went to the local video store to rent some movies. Teresa brought back 12 but 4 were too scary for you so you returned them. On that trip you came home with 7 new movies. How many are you going to watch this afternoon? You could work this out yourself, but here is a BASIC program that can do the arithmetic for you. Type in: 10 PRINT 12-4+7 20 END press ENTER press ENTER Now type RUN and press ENTER. What happens? The answer, 15, appears on the screen. In BASIC, you write a series of line-numbered statements that tell the PRECOMPUTER POWER PAD™ PLUS what to do. The first statement, numbered 10, tells the computer to work out the sum of three numbers and then PRINT the answer on the screen. The next statement, number 20, tells the computer that this is the end of the program and that it can stop RUNNING. However, the last statement is not necessary in this program because you only want to print out the sum of 3 numbers, therefore, it could be removed. Remove that last line by typing 20 and press ENTER. Now type RUN and press ENTER. What happens? You get the same results. Suppose you typed: 10 PRONG 12-4+7 press ENTER Now type RUN and press ENTER. What happens? You get a strange message, "? SYNTAX ERROR IN 10" in the display. That means you made a mistake in BASIC grammar and this is the PRECOMPUTER POWER PAD™ PLUS unit's way of telling you this. You need to EDIT the line or re-type it, changing "PRONG" to "PRINT" and then RUN the program again to get the correct answer. You can use PRECOMPUTER POWER PAD™ PLUS as a calculator in arithmetic statements like the one above by not using a line number. Just type: PRINT 12-4+7 press ENTER The answer will appear on the screen. Another short cut is that you could use the "?" symbol to stand for the word "PRINT." When you are using BASIC as a calculator in "command mode", think of the question mark as meaning "What is 12-4+7?" When you are using the question mark as a "PRINT" command in a program, the computer will replace the "?" with the word "PRINT" for you. 34

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

34
BASIC COMPUTER TUTORIAL
EXAMPLE OF A BASIC PROGRAM
You and Teresa went to the local video store to rent some movies.
Teresa brought back
12 but 4 were too scary for you so you returned them.
On that trip you came home with
7 new movies.
How many are you going to watch this afternoon?
You could work this
out yourself, but here is a
BASIC
program that can do the arithmetic for you.
Type in
:
10
PRINT
12-4+7
press
ENTER
20
END
press
ENTER
Now type
RUN
and press
ENTER
. What happens?
The answer, 15, appears on the screen.
In
BASIC
, you write a series of line-numbered statements that tell the
PRECOMPUTER
POWER
PAD™ PLUS
what to do.
The first statement, numbered 10, tells the computer
to work out the sum of three numbers and then
PRINT
the answer on the screen.
The
next statement, number 20, tells the computer that this is the end of the program and that
it can stop
RUNNING
. However, the last statement is not necessary in this program because
you only want to print out the sum of 3 numbers, therefore, it could be removed.
Remove that last line by typing 20 and press
ENTER
.
Now type
RUN
and press
ENTER
.
What
happens?
You get the same results.
Suppose you typed
:
10
PRONG 12-4+7
press
ENTER
Now type
RUN
and press
ENTER
. What happens?
You get a strange message, “
?
SYNTAX
ERROR IN
10
” in the display.
That means you made a mistake in
BASIC
grammar and
this is the
PRECOMPUTER POWER PAD™ PLUS
unit’s way of telling you this.
You need
to
EDIT
the line or re-type it, changing “
PRONG
” to “
PRINT
” and then
RUN
the program
again to get the correct answer.
You can use
PRECOMPUTER POWER PAD™ PLUS
as a calculator in arithmetic statements
like the one above by not using a line number.
Just type
:
PRINT 12-4+7
press
ENTER
The answer will appear on the screen.
Another short cut is that you could use the “
?
” symbol to stand for the word “
PRINT
.”
When
you are using
BASIC
as a calculator in “command mode”, think of the question mark as
meaning “What is 12-4+7?” When you are using the question mark as a “
PRINT
” command
in a program, the computer will replace the “
?
” with the word “
PRINT
” for you.