EasyManua.ls Logo

Commodore 128D - The SLEEP Command; Formatting Output; The PRINT USING Command

Commodore 128D
427 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
This
program
asks
for
a
number
from
the
user.
IF
the
number
is
less
than
100,
the
statements
between
the
keywords
BEGIN
and
BEND
are
performed,
along
with
any
statements
on
the
same
line
as
BEND
(except
for
ELSE).
The
message
"YOUR
NUMBER
WAS
Nr
appears
on
the
screen.
Line
50
is
a
delay
loop
used
to
keep
the
message
on
the
screen
long
enough
so
it
can
be
read
easily.
Then
a
FOR/NEXT
loop
is
used
to
display
a
message
for
the
number
of
times
specified
by
the
user.
If
the
number
is
greater
than
100,
the
THEN
condition
is
skipped,
and
the
ELSE
condition
(printing
"TOO
MANY")
is
carried
out.
The
ELSE
keyword
must be
on
the
same
line
as
BEND.
The
SLEEP
Command
Note
the
use
of
the
SLEEP
command
in
line
50
of
the
program
just
discussed.
SLEEP
provides
an
easier,
more
accurate
way
of
insert
ing
and
timing
a
delay
in
program
operation.
The
format
for
the
SLEEP
command
is
SLEEP
n
where
n
indicates
the
number
of
seconds,
in
the
range
1
to
65535,
that
you
want
the
program
to
delay.
In
the
command
shown
in
line
50,
the
2
specifies
a
delay
of
two
seconds.
U
U
Formatting
Output
The
PRINT
USING
Command
Suppose
you
were
writing
a
sales
program
that
calculated
a
dollar
amount.
Total
sales
divided
by
number
of
salespeople
equals
aver
age
sales.
But
performing
this
calculation
might
result
in
dollar
amounts
with
four
or
five
decimal
places!
You
can
format
the
results
the
computer
prints
so
that
only
two
decimal
places
are
displayed.
The
command
which
performs
this
function
is
PRINT
USING.
PRINT
USING
lets
you
create
a
format
for
your
output,
using
spaces,
commas,
decimal
points
and
dollar
signs.
Hash
marks
(the
#
sign)
are
used
to
represent
spaces
or
characters
in
the
displayed
result.
For
example:
PRINT
USING
"#$#####.##";A
tells
the
computer
that
when
A
is
printed,
it
should
be
in
the
form
given,
with
up
to
five
places
to
the
left
of
the
decimal
point,
and
two
places
to
the
right.
The
hash
mark
in
front
of
the
dollar
sign
indicates
that
the
$
should
float;
that
is,
it
should
always
be
placed
next
to
the
left-most
number
in
the
format.
78
USING
C128
MODE—Some
BASIC
Commands
and
Keyboard
Operations
Unique
to
C128Mode

Table of Contents

Other manuals for Commodore 128D

Related product manuals