Since ENDWHILE serves to terminate a while loop (which is started by the WHILE keyword), it should not appear before WHILE. Here is an example of a correct while loop:
while x > 3 x = sqr(x) + y endwhile
See Also Errors