END Statement

The END statement designates the end of a program or the end of a group of statements begun with a THEN or ELSE clause.

Format

END

Description

Use the END statement to terminate an mvBASIC program or a clause within an IF, file I/O, tape I/O, floppy disk I/O, or communications statement.

An END statement may be the last statement in an mvBASIC program, but it is not mandatory. When an END statement that is not associated with an IF or I/O statement is encountered, all subsequent lines of the program are ignored by the mvBASIC compiler. Note that any subroutines which may have been entered after a program END statement are not recognized.

In using the END statement with multiple conditional statements, it is recommended that care be taken to use the correct number of END statements. A missing END statement, or an extra one, may drastically affect the logic of a program (or prematurely terminate it) without an error message being printed.

Example

In this example, END statements are used with nested IF constructs and the last END is interpreted by the compiler as the end of the program.

SUIT = RND(4)    

IF SUIT = 0 THEN SUIT = "CLUBS" ELSE    

   IF SUIT = 1 THEN SUIT = "DIAMONDS" ELSE

      IF SUIT = 2 THEN SUIT = "HEARTS" ELSE   

         IF SUIT = 3 THEN SUIT = "SPADES"        

      END    

   END        

END  

NUM = RND(13)

   .

   .

   .

END

See Also

Statement and Function Reference