ELSE or ELSEIF after ELSE is not allowed

After ELSE, only ENDIF may follow. Here is an example of a correct IF statement:

if x > 3
  a = 1
elseif x > 2
  a = 2
else
  a = 3
endif

See Also
Errors