EasyManua.ls Logo

IBM 5100 - Page 142

IBM 5100
228 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...
138
Labels are local
to
a
function-which
means
they
can
only
be used
within
that
function. Following are some additional rules
that
apply
to
the
use
of
labels:
They must
not
appear in
the
function
header.
You
cannot
assign values
to
them.
They can be
up
to
77 characters in length.
They
cannot
be used
on
comments.
When duplicate labels
or
labels
that
duplicate a local name are used,
the
first
use
of
the
label
or
name
is
the
accepted use.
If
the
branch
is
to
zero (-+())
or
any
statement
number
not
in
the
function,
the
function
i's
exited when
the
branch
statement
is
executed.
If
the
value
to
the
right
of
the
-+
is
a vector (for example,
~L
1 ,L2,L3),
the
branch
is
determined
by
the
vector's first element.
If
the
vector
is
an
empty
vector (there are no elements),
the
branch
is
not
executed,
and
the
normal sequence
of
statement
execution continues.
For example,
the
conditional branch
~(I
~N)/START
is
evaluated as follows:
1. First,
the
condition
(I
~
N)
is
evaluated;
the
result
is
1 if
the
condition
is
true
and 0 if
the
condition
is
false.
2.
The
result
of
step
1
is
then
used as
the
left
argument
for
the
compress
(A/B)
function:
a. If
the
result
of
step
1 was 1,
START
is
selected from
the
right
argument
and a branch
to
the
statement
labeled
START
is
taken.
b. If
the
result
of
step
1 was
0,
nothing
is
selected from
the
right
argument
(an
empty
vector
is
the
result) and
the
sequence
of
execution
falls
through
to
the
next
statement.
Following are
three
examples
of
defining and using a
function
to
determine
the
sum
of
the
first N integers. Each
function
uses a
difterent
method
of
branching.
Remember,
the
expression
to
the
right
of
the
~
is
evaluated
and
the
result deter-
mines
to
what
statement
the
branch
is
taken:
I:
:1.:1
[2]
[:3]
[1+]
[!7j J
[6J
'V
Sf·SUM:L N
s~··o
14.··:1.
CHECK
:
··~I...~lHEI
..•
X I
::;N
.....
i----Branch
to
LABEL if
I$N;
otherwise,
LABEl
...
:
S~"S+
I
exit
the
function.
I~'I+l
"~CHECK'V
SUM:I.
5
I~,",}
''<I
••

Table of Contents

Other manuals for IBM 5100

Related product manuals