Sample Program; Storing And Reusing Your Programs - Commodore 128D User Manual

Hide thumbs Also See for 128D:
Table of Contents

Advertisement

Sample Program
Storing and
Reusing Your
Programs
See how you can print numeric and string variables in the same
statement? Try experimenting with variables in your own short
programs.
You can print the value of a variable in DIRECT mode, after the pro
gram has been RUN. Type ?A$;B$;X;Y after running the program
above and see that those four variable values are still in the comput
er's memory.
If you want to clear this area of BASIC memory but still leave your
program intact, use the CLR command. Just type CLR <RETURN)
and all constants, variables and strings are erased. But when you
type LIST, you can see the program is still in memory. The NEW com
mand discussed earlier erases both the program and the variables.
Here is a sample program incorporating many of the techniques and
commands discussed in this section.
This program calculates the average of three numbers (X, Y and Z)
and prints their values and their averages on the screen. You can
edit the program and change the assignments in lines 10 through 30
to change the values of the variables. Line 40 adds the variables and
divides by 3 to get the average Note the use of parentheses to tell
the computer to add the numbers before it divides.
TIP: Whenever you are using more than one set of parentheses
in a statement, it's a good idea to count the number of left
parentheses and right parentheses to make sure they are
equal.
10X = 46
20Y = 72
30Z = 114
40A = (X + Y + Z)/3
60 ?"THE AVERAGE OF"X;Y;"AND "Z;"IS"A;
90 END
Once you have created your program, you will probably want to store
it permanently so you will be able to recall and use it at some later
time. To do this, you'll use either the Commodore disk drive or the
Commodore 1530 Datassette.
41
USING C128 MODE-Getting Started in BASIC

Advertisement

Table of Contents
loading

Table of Contents