GOTO

Example

GOTO provides a method of transferring control within your TSP program, that is, of changing the order in which the statements are executed. However, modern programming theory suggests that the use of GOTO statements should be avoided since they tend to produce unreadable and hard to debug programs. In TSP, the DO loop facility and IF-THEN-ELSE syntax can be used to avoid the use of GOTO statements.

GOTO statement number ;

or

GO TO statement number ;

Usage

A GOTO statement consists of GOTO followed by a statement number which must been defined somewhere in your program. The effect of the statement is to transfer control immediately to that statement. [Note that the GOTO statement cannot be used to transfer to the data section of your program; you can use a series of LOAD statements instead.]

Example

IF A; THEN ; GO TO 100 ;

    B = K*K ;

GOTO 200 ;

100 B = K*K*10000 ;

200 OLSQ Y C B ;

This example shows the GOTO statement being used to create two branches of the program, one to be executed if A is false, and one to be executed if A is true. The same thing can be done with an IF-THEN-ELSE sequence:

IF A ; THEN ;

     B = K*K*10000 ;

ELSE ;

     B = K*K ;

OLSQ Y C B ;