`prev Menu next`

ELSEIF ☆☆

(1) An IF ～ END IF block can contain an ELSEIF line.

    IF logical_exp1 THEN
      ………1
    ELSEIF logical_exp2 THEN
      ………2
    ELSE
      ………3
    END IF

is equivalent to

    IF logical_exp1 THEN
      ………1
    ELSE
      IF logical_exp2 THEN
        ………2
      ELSE
        ………3
      END IF
    END IF

If logical_exp1 is true, ………1 shall be executed, otherwise logical_exp2 is true, ………2 shall be executed, otherwise ………3 shall be executed.
Example.

      ! Solve a quadratic equation
      INPUT a, b, c
      LET D=b^2-4*a*c
      IF D>0 THEN
         PRINT (-b+sqr(D))/(2*a),(-b-sqr(D))/(2*a)
      ELSEIF D=0 THEN
         PRINT -b/(2*a)
      ELSE
         PRINT "no solution"
      END IF
      END

(2) An IF～END IF block can contain more than one ELSEIF line.
`IF logical_exp1 THEN
………1
ELSEIF logical_exp2 THEN
………2
ELSEIF logical_exp3 THEN
………3
～～～
～～～
ELSEIF logical_expn-1 THEN
………n-1
ELSE
………n
END IF`