EasyManua.ls Logo

Sharp MZ-700 - Page 55

Sharp MZ-700
213 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...
2. 3. 6. 5
IF,.....,
GOTO
.......
.
.....
.
...
.
..
.
........
. . (abbreviated format:
IF,.....,
G.)
I Format I
IF
e GOTO Lr
Function
Example
e: Relational expression
or
logical expression
Lr: Destination line
number
This statement sequence evaluates the condition defined
by
relational
or
logical
expression e, then branches
to
the line
number
specified in Lr
if
the condition
is
satisfied.
As
with the
IF
.
..
THEN sequence,
IF
,.....,
GOTO
is
used for conditional
branching; when the specified condition is satisfied, program execution
jumps
to
the
line
number
specified in Lr.
If
the
condition is
not
satisfied, execution continues
with the
next
line
of
the program. (Any statements following
IF
,.....,
GOTO
on
the
same program line will be ignored.)
1 0
G=
0
:N=
0
2 0
INPUT.
"
GRADE=
" ; X
3 0
IF
X
=999
GOTO 1
00
4 0
T=T+
X
:N=N+1
5 0
GOTO
2 0
1
00
PRINT
----------
11
0
PRINT
"
TOTAL:
"
;T
1 2 0
PRINT
"
NO
.
PEOPLE
: " ; N
13
0
PRINT
"AV
ERAGE
:"
;T
/ N
14
0 END
2. 3. 6. 6
IF,.....,
GOSUB
.........................
..
..
(abbreviated format:
IF,.....,
GOS.)
I Format I
IF
e GOSUB Lr
Function
Example
e: Relational expression
or
logical expression
Lr: Destination line
number
This
statement
evaluates the condition defined by relational
or
logical expression e,
then,
if
the condition
is
satisfied, branches to the subroutine beginning on the
line
number
specified in Lr. Upon completion
of
the subroutine, execution returns
to
the first executable statement following the calling
IF
,.....,
GOSUB statement;
therefore,
if
multiple statements are included
on
the line with the
IF
,.....,
GOSUB
statement, execution returns
to
the
first statement following
IF
,.....,
GOSUB.
1 0 I N
PUT
X= " ; X
2 0
IF
X<0
GOSUB
1
00
:PRINT
"X<0
"
30
IF
X=0
GOSUB
2
00:
PRINT
"X=0 "
4 0
IF
X>0
GOSUB
3
00:
PRINT
"
X>0
"
5 0
60
1
00
2
00
3
00
PRINT
----------------------
GOTO 1 0
PRINT
*
PROGRAM
LINE
1
00
"
:RETURN
PRINT
*
PROGR
AM
LINE
2
00
"
:RETURN
PRINT
*
PROGRAM
LINE
3
00
" :
RETURN
----------------------------
----
----------------------------------
----
--
--53

Other manuals for Sharp MZ-700

Related product manuals