Exit Do statement - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
ft:locale
en-US
Product name
MapBasic
ft:title
MapInfo MapBasic Reference
First publish date
1985
ft:lastEdition
2023-09-12
ft:lastPublication
2023-09-12T16:32:32.686000

Purpose

Exits a Do...Loop statement prematurely.

Restrictions

You cannot issue an Exit Do statement through the MapBasic window.

Syntax

Exit Do

Description

An Exit Do statement terminates a Do...Loop statement. Upon encountering an Exit Do statement, MapBasic will jump to the first statement following the Do...Loop statement. Note that the Exit Do statement is only valid within a Do...Loop statement.

Do...Loop statements can be nested; that is, a Do...Loop statement can appear within the body of another, "outer" Do...Loop statement. An Exit Do statement only halts the iteration of the nearest Do...Loop statement. Thus, in an arrangement of this sort:

Do While condition1 
:
	Do While condition2 
		:
		If error_condition
			Exit Do
		End If 
		: 
	Loop
	:
Loop

the Exit Do statement will halt the inner loop (Do While condition2) without necessarily affecting the outer loop (Do While condition1).

See Also:

Do...Loop statement, Exit For statement, Exit Sub statement