EasyManua.ls Logo

HP HP-28S - Page 225

HP HP-28S
341 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
Loading...
Here's
how
this structure works
when
you execute
the
program:
1.
The
IF
command
simply
marks
the
start
of
the
structure.
It
can
be
anywhere
before
the
THEN
command.
2. X is evaluated.
3.
The
number
0 goes
on
the
stack.
4.
The
command
~
takes
the
value
of
X
and
the
number
0 as
arguments.
If
the
arguments
are
"not equal",
~
returns
1.
If
the
arguments
are not "not equal",
~
returns
o.
5.
The
command
THEN
takes 1
or
0 as its
argument.
If
its
argument
is 1,
THEN
evaluates
the
program
up
to ELSE
(namely
:x:
::::
I
t~
:x:
./).
If
its
argument
is
0,
THEN
evaluates
the
program
from ELSE
to
END
(namely 1).
6.
Program
execution
continues
after
the
END
command.
Before
continuing
with
specifics
about
conditional
structures,
here's
some
general
information
about
program
structures.
Program-Structure Commands.
The
commands
IF,
THEN, ELSE,
and
END
are examples
of
program-structure commands.
The
order
and
meaning
of
these
commands
are similar to their use
in
English.
You
can't
use
program-structure
commands
as flexibly as
other
commands;
they
work
only in
the
combinations
described
in
this chapter.
Test Functions and Commands.
The
function
~
is called a test
function.
Given
two
numbers,
~
returns
1
or
0,
indicating
whether
the
test is true
or
false.
Other
test
functions
are <,
;.,
~,>,
and
==.
(Re-
member
that
= is
used
for
equations,
not
to test equality.)
Given
symbolic
arguments,
test
functions
return
a symbolic result.
There
are also test
commands
that
always
return
1 or
O.
For example,
the
test
command
SAME is similar
to
=
=,
but
it simply tests
whether
the
two objects
are
identical.
Additional
test
commands
are
available
for working
with
flags (described next). For
more
information
about
test
functions
and
commands,
see "PROGRAM TEST'
in
the
Refer-
ence Manual.
224
26:
Program
Structures

Table of Contents

Other manuals for HP HP-28S

Related product manuals