Goto statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Jumps to a different spot (in the same procedure), identified by a label.

Restrictions

You cannot issue a Goto statement through the MapBasic window.

Syntax

Goto label

label is a label appearing elsewhere in the same procedure.

Description

The Goto statement performs an unconditional jump. Program execution continues at the statement line identified by the label. The label itself should be followed by a colon; however, the label name should appear in the Goto statement without the colon.

Generally speaking, the Goto statement should not be used to exit a loop prematurely. The Exit Do statement and Exit For statement provide the ability to exit a loop. Similarly, you should not use a Goto statement to jump into the body of a loop.

A Goto statement may only jump to a label within the same procedure.