Recent Changes - Search:

Basics

Languages

Tools

OS

Resources

PmWiki

pmwiki.org

edit SideBar

GoTo Statements

Goto statements are a very convenient if messy way to get around code. The common structure,

GOTO N
(some code here)
N
(more code here)

where N is a number, will immediately send the program to the line of code with the N marker, bypassing all that is written between the GOTO and the N line. Too many goto statements can make code incredibly messy. A few here and there can make things much easier.

A more advanced structure is

%codebox
 GOTO (N,M,...) e
(some code here)
N
(more code here)
M
(even more code here)

where e is an integer variable or a statement that evaluates to an integer. The value of e will then determinate which line the code goes to. In the above, a value of 1 means the code goes to N, while 2 sends it to M.

Edit - History - Print - Recent Changes - Search
Page last modified on October 13, 2015, at 08:57 PM