2.
1 Introduction to Programming
in
BASIC
2.1.1
Direct Mode
Now
that
you
have made some key entries on the MZ-700,
you
have reached the
point
where
you
are ready
to
start learning
how
to
program. Before
you
start, however, try using the
MZ
-
700
as
you
would an ordinary
pocket
calculator. (This
is
called operating the MZ-700 in the
"direct
mode"
.) Key
in
the
following,
just
as
you
would on a
pocket
calculator.
As
you
can see, the
computer
doesn't do anything when
it
is
presented with a problem in this form;
your
computer
and an ordinary calculator are completely different in this respect, and instructions
must
be entered in a form which can be understood
by
the
computer
(i.e, in
the
form prescribed
by
the BASIC
language). Now
try
typing in
the
following.
If
you
have done this correctly, the
number
"13"
will be displayed and the screen will appear
as
shown
below.
READY
PRINT
4+9
1 3
READY
PRINT
is an instruction which tells
the
computer
to
display
something
on
the screen. Here,
the
computer
is instructed
to
display the sum
of
4 +
9.
Now let's
try
doing a somewhat more complex calculation.
With BASIC
for
the
MZ
-700,
the
operators (symbols) for the basic arithmetic operations are
as
follows.
Addition:
+
Subtraction:
Multiplication: *
Division: /
Exponentiation:
t
(the
asterisk)
(the
slash)
When symbols such a
" *
",
" +
",
and " t " are mixed together in a single arithmetic expression,
the order in which calculations indicated
by
the symbols are performed
is
referred
to
as
their priority.
Just
as
with ordinary algebra, operations can be included in parentheses, so operations within the inner-
most
set
of
parentheses are performed first. Within a set
of
parentheses, exponentiation
is
performed
first, followed
by
multiplication and division (which have equal priority, and therefore are performed
as
they are encountered in the expression, from left
to
right), and
then
by
addition and subtraction.
For
example,
to
obtain the answer
to
the expression 3 x 6 x (6 + 3 x
19-
2 x
(4-
2) +
If
J,
enter
the
following.
Now
try
using the
computer
to
do
a variety
of
other
problems in arithmetic.
16
------------------------------------------------------
--------
--
-------