# GOTO

GOTO Example

Syntax: GOTO Address

## Function

Jump the point in the program specified by Address.

- Address is a label that specifies where to go.

## Quick Facts

| BS1 | All BS2 Models
Related Commands | BRANCH, GOSUB | ON...GOTO, BRANCH, GOSUB
Max. GOTOs per program | Unlimited, but good programming practices suggest minimizing the use of GOTO.

## Explanation

The GOTO command makes the BASIC Stamp execute the code that starts at the specified Address location. The BASIC Stamp reads PBASIC code from left-to-right, top-to-bottom, just like in the English language. The GOTOcommand forces the BASIC Stamp to jump to another section of code.

A common use for GOTO is to create endless loops; programs that repeat a group of instructions over and over. For example:

    Hello:
      DEBUG "Hi", CR
      PAUSE 500
      GOTO Hello

The above code will print "Hi" on the screen, over and over again. The GOTO Hello line simply tells it to go back to the code that begins with the label Hello.

Go to Welcome page

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/8/2012