Previous Topic

Next Topic

Book Contents

Book Index

MaxBasic Statements

Scripts consist of a series of statements. They start by executing the first statement in the script and then proceed to the last. Statements provide the building blocks that allow programs to be created (for example, assignment, branching, or looping). Multiple statements can be placed on a single line by separating with the colon (:) character. A statement must be contained in one line (except specific multi-line statements such as IF...THEN...ELSE, documented below).

Statement

Description

AddressOf

Returns reference to a subroutine or function. Used to assign event handlers to events.

Assignment

Assigns the value of an expression to a variable or a (writeable) object property.

Call

Call a subroutine or function.

Const

Declare a constant value.

Dim

Declares variables and allocates storage space.

Do...Loop

Repeats a block of statements while a condition is True or until a condition becomes True.

Erase

Used to release array variables and de-allocate the memory used for their elements.

Error

Raises a program exception of User Error and terminates the active process. This is commonly used in scripting to terminate a script on an error condition.

For...Next

Repeats a group of statements a specified number of times.

Function...End Function

Declares the name, arguments, and code that define a Function procedure.

If...Then...Else If...Else...End If

A compound multi-line statement designed to allow conditional execution of other statements. There is also an abbreviated single line version.

Imports

Imports another script source file into the current script file.

Option Compare

Allows control over how comparisons are performed.

Option Print

Allows control over what happens after every print statement and how strings are delimited.

Option Window

PrintReplace statement

Controls how forms created using CreateObject forms are opened.

Print

Outputs the value of an expression to the output stream.

PrintReplace

Replaces the last line in the output stream with the value of an expression.

Public

Declares global variables and allocates storage space.

ReDim

Used to size or resize a dynamic array formally declared using a Dim statement.

Rem

Used for adding comments (or remarks) that are not executed by MaxBasic.

Return

Returns control to the code that called a Sub or Function procedure.

Select Case

Executes one of several groups of statements, depending on the value of an expression.

Sub...End Sub

Declares the name, arguments, and code that define a Sub procedure.

Throw

Use to re-throw caught exceptions, the re-throws retain the original message and source path.

Try...Catch...Finally...End Try

A compound multi-line statement designed to allow exception handling for block of statements.

In This Section

AddressOf statement

Assignment statement

Call statement

Const statement

Dim statement

Do...Loop statement

Erase statement

Error statement

For...Next statement

For Each...Next statement

Function...End Function statement

If...Then...Else If...Else...End If statement

Imports statement

Option Compare statement

Option DisableAutoApply statement

Option Print statement

Option Window statement

Print statement

PrintReplace statement

Public statement

ReDim statement

Rem statement

Return statement

Select Case statement

Sub...End Sub statement

Throw statement

Try...Catch...Finally...End Try statement