EasyManuals Logo
Home>Texas Instruments>Desktop>TI-99/4A

Texas Instruments TI-99/4A User Reference Guide

Texas Instruments TI-99/4A
204 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #71 background imageLoading...
Page #71 background image
IF-THEN-ELSE
IF
\reJatio~al-expres~ion}THEN
line-IIELSE
line-21
~
numCrIc-eXpreSGlOn
The
IF·THEN
-ELSE
statement allows you to change the normal
sequence of your program execution
by
using a conditional
branch.
The
computer evaluates
the
expression you have included in the
1)lalemenl,
1)uch
as
A>50.
If
the
expression
is
true,
the
computer
will jump to line-}, which follows the word
THEN.
If
the condition
is
false,
the
computer will jump to line-2 following the word
ELSE.
If
ELSE
i::)
ulllillcu,
Llle
cumpuLer
conLinues
with
the
next
program
line.
In
an
IF·THEN
·ELSE
~tatement.
a value
of
0 is treated
as
false.
and
any other value
is
treated
as
true.
Thus,
you can use
multiplication
as
a logical·AND and addition
as
a logical-OR.
For
example.
IF
(A<B)*(C<D)
THEN
1000
will go to line 1000 if A is less than
Band
C
is
less than D.
The
allowable relational operators in
TI
BASIC are:
equal to (
==
)
less
than
(
<)
greater
than
(»
not equal to « »
less
than
or
equal
to
(
<'
=)
greater than or equal to (>
=)
Here
are
some valid relationship tests:
.A>7
.A$<"YES'·
(A
+
B}J2<>AVG
CHR$(L)="A"
(A$&C$) > =D$
A
numeric-expression must be compared to another numeric'
expression
and
a string-expressIOn to another string-expression.
Numeric-expressions
are compared algebraically. String·
expressions
are
compared left-to-right.
character
by character.
using the ASCII character codes. A
character
with a lower
ASCII code will be considered less than one with a higher ASCII
code. Thus, you
can
sort strings into numeric or alphabetic
order.
If
one string
is
longer
than
the other, the comparison
is
made
for each
character
in the shorter string.
If
there is no
difference. the computer considers the longer
string
to be greater.
Examples:
>NEW
>100
RFM
FIND
THE
LARGEST
OF
A
SET
OF
NUMBERS
>110
INPUT
"HOW
MANY
VALUES?"
: N
>120
INPUT
"VALUE?":A
>130 l=A
>140
N=N-1
>150 IF
N<=O
THEN
180
>160
INPUT
"VALUE?":A
>170 IF
L>A
THEN
140
ELSE
130
>180
PRINT
L;"IS
THE
LARGEST"
>190
END
>RUN
HOW
MANY
VALUES?3
VALUE?456
VALUE?321
VALUE?292
456
IS
THE
LARGEST
**
DONE
**
>NEW
>100
INPUT
"A$
IS
":A$
>110
INPUT
"BS
IS
":B$
>120 IF
A$=B$
THEN
160
>130 IF
A$<BS
THEN
180
>140
PRINT
"B$
IS
LESS"
>150
GOTO
190
>160
PRINT
"A$=BS"
>170
GOTD
190
>180
PRINT
"B$ IS
GREATER"
>190
END
>RUN
AS
IS TEXAS
B$
IS TEX
BS
IS
LESS
**
DONE
**
)RUN
AS
IS
TAXES
B$
IS
TEX
8$ IS
GREATER
**
DONE
**

Other manuals for Texas Instruments TI-99/4A

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TI-99/4A and is the answer not in the manual?

Texas Instruments TI-99/4A Specifications

General IconGeneral
BrandTexas Instruments
ModelTI-99/4A
CategoryDesktop
LanguageEnglish

Related product manuals