Program Fundamentals - Radio Shack TRS-80 PC-4 Owner's Manual

Trs-80 pc-4
Hide thumbs Also See for TRS-80 PC-4:
Table of Contents

Advertisement

• How to Count the Number of Steps
A command
or
a function command in a program uses 1 step.
A line number (numerical values from 1 through 9999) uses 2 steps.
Example:
1 I NPUT A
Im--------------------------------
5
steps
' - - '
\
I
'~
' - - - '
2
I
10 8
=
SIN A
E··------------------------------
7
steps
'--J
'---JL...J~
I...-.J ' - - '
2
I I
I
I
100 PRINT
"-----'
\
}
2
\\ 8="
; B
LED
------------···10
steps
,
'--..I
L..J '----'
4
I
I
Total 22 steps
5-2-1 Constants and Variables
Characters which can be used in BASIC are capital letters (A through Z) and numbers (0
through 9) and certain special characters such as symbols, etc.
• Constants
The characters used in BASIC are capital letters (A through Z), and numbers
(0
through
9), and certain special characters such as symbols.
Example: S
=
1tr
2
becomes
S
= 1!
*
R
f
2
2 is the constant .
• Variables
A variable is a single capital letter (A through Z) or a single capital letter with
"$"
attached (character variable).
Variables are also numerical values which are used in a program. They are used during
execution to make inputs from the keyboard or to substitute calculation results which
were initially unknown.
Example:
S
=
1Cr
2
becomes S
=
7C
*
R
f
2
R is the variable.
Example: Y
=
2
*
X
t
2
+
3
*
X
+
4
V~riable
I
va~iable
I
con~ant
I
Co~stant
Constant
Constant
Variable
In other words, algebraic terms are "variables" and constant numbers are "constants".
In addition, there are character constants and character variables.
A character constant is a character string which is written directly. A character string
is a group of characters which is enclosed in quotation marks such as
"123"
or "ABC".
-28-

Advertisement

Table of Contents
loading

Table of Contents