Comet 32 Runtime
The RETURN statement transfers program control to the statement
immediately following the most recently invoked subroutine call.
All subroutine calls in Internet Basic place a "return address" in a subroutine stack. The RETURN statement simply transfers program control to the address on the top of this stack. It also removes or "pops" the address from the top of the stack so that a subsequent RETURN statement will use the next address it finds on the top of the stack.
Executing a RETURN statement with no return address in the subroutines stack causes a "GOSUB STACK UNDERFLOW" exception condition.
Processing continues in the subroutine until the program encounters the RETURN statement. At this point, control is transferred back to the main section of the program (to the statement immediately after the GOSUB 1000 statement).
The STOP statement is included in the main section of the program to prevent program flow from entering the subroutine without using the GOSUB statement.