E-116
Example
Lbl 1 : ?
→
A : A
>
0
S
'
(A)
^
Goto 1
A
Control Structure Commands: If Statements
The If statement is used to control program execution branching according to whether the
expression following If (which is the branching condition) is true or false.
If Statement Precautions
• An If statement must always be accompanied by a Then statement. Using an If without a
corresponding Then will result in a Syntax ERROR.
• An expression, Return, or Stop command can be used for the <expression*> following
Then and Else.
If ~ Then (~ Else) ~ IfEnd
Syntax
If <conditional expression> : Then <expression*> : Else <expression*> :
IfEnd : <statement> : ...
Function
• The statements following Then are executed up to Else, and then the
statements following IfEnd are executed when the conditional statement
following If is true. The statements following Else and then the statements
following IfEnd are executed when the conditional statement following If is
false.
• “Else<expression>” may be omitted.
• Always include the “IfEnd”. Omitting it will not cause an error, but certain
program contents can cause unexpected execution results by everything
after the If statement.
Example 1
?
→
A : If A < 10 : Then 10A
^
Else 9A
^
IfEnd : Ans×1.05
Example 2
?
→
A : If A > 0 : Then A×10
→
A : IfEnd : Ans×1.05
A
Control Structure Commands: For Statements
The For statement repeats execution of the statements between For and Next as long as
the value assigned to the control variable is within the specifi ed range.
For Statement Precautions
A For statement must always be accompanied by a Next statement. Using a For without a
corresponding Next will result in a Syntax ERROR.
For ~ To ~ Next
(COMP)
Syntax
For <expression (start value)>
→
<variable (control variable)> To <expression
(end value)> : <statement> : ... <statement> : Next : ...
Function
Execution of the statements from For to Next repeats as the control variable
is incremented by 1 with each execution, starting from the starting value.
When the value of the control value reaches the ending value, execution
jumps to the statement following Next. Program execution stops if there is no
statement following Next.
Example
For 1
→
A To 10 : A
2
→
B : B
^
Next
Summary of Contents for fx-5800P
Page 1: ...fx 5800P User s Guide http world casio com edu RJA516644 001V01 E ...
Page 139: ...E 138 MEMO ...
Page 140: ...E 139 MEMO ...
Page 141: ...E 140 MEMO ...
Page 142: ...E 141 MEMO ...
Page 143: ...E 142 MEMO ...
Page 144: ...E 143 MEMO ...
Page 145: ...E 144 MEMO ...