goto Statement

Purpose:

Pass control to the given label

Syntax:

call label

 

Comments:

The goto statement should be avoided since it tends to produce spaghetti code but there are uses as shown in the example below

 

Example:

// do something  // gather data

// sort the data  // sorts it

 

// process the sorted data

 

Now say you are working in this program but are having trouble with process the sorted data section.  Each time you run the program you have to wait for gather data and sort to finish.  This can be counter productive.

 

So heres the solution.  Use the goto statement as shown below

 

goto missit

// do something  // gather data

// sort the data  // sorts it

missit:

// process the sorted data

 

Now when the program runs, it will jump directly to the missit label.  When you have the process sorted data code working, you can remove the goto statement.