Skip to content

Control Flow Statements

Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › Control Flow Statements › Control Flow Statements

Control Flow Statements

Statements that direct the flow of program execution.

Transferring Statements

Statements that transfer control to another part of a program.

Branching Statements

Statements that execute one of a number of code branches.

Looping Statements

Statements that execute code repeatedly.

Transferring Statements

Goto

Transfers execution to another point in code defined by a text label.

GoSub

Temporarily transfers execution to another point in code, defined by a text label.

On Goto

Transfers execution to one of a number of points in code defined by text labels, based on the value of an expression.

On Gosub

Temporarily transfers execution to one of a number of points in code defined by text labels, based on the value of an expression.

Return (From Procedure)

Returns from a procedure returning a value.

Return (From Gosub)

Returns from a call using GoSub.

Exit Sub, Exit Function, Exit Operator, Exit Constructor, Exit Destructor and Exit Property

Prematurely leaves a procedure code block.

Branching Statements

If..End If

Executes a block of statements if a condition is met.

..Else If..

Executes a block of code if a condition is met and all previous conditions weren't met.

..Else..

Executes a block of code if all previous conditions weren't met.

Select..End Select

Executes one of a number of statement blocks using a set of conditions.

..Case..

Executes a block of code if a condition is met.

..Case Else..

Executes a block of code if all previous conditions weren't met.

Intra-branch control

Exit Select

Prematurely breaks out of a Select..End Select statement.

Looping Statements

While..Wend (Or 'While...End While')

Executes a block of statements while a condition is met.

For..Next

Executes a block of statements while an iterator is less than or greater than an expression.

Do..Loop

Executes a block of statements while or until a condition is met.

Intra-loop control

Continue While, Continue For and Continue Do

Prematurely re-enters a loop.

Exit While, Exit For and Exit Do

Prematurely breaks out of a loop.


Category: Control Flow Statements


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally