Reference Manual - Table of Contents

Execution Control
Forms and Windows
Controls
Menus
System and Desktop
Graphic Drawing Commands

Animation
QuickTime Movies
Speech
Sound
File I/O
Printing
Serial Ports

Math Functions
String Functions
Date and Time
Memory Buffers
Error Handling
Console Text Window

Events

Direct Memory Access
Direct Mouse Access
Direct Keyboard Access
Code Resource Modules

A - Runtime Error Messages
B - Compiler Error Messages

 

Execution Control

The commands in this section control the flow of execution of your program.

Command Summary:

 

Goto label

Goto line#

This command will do an unconditional jump which will branch program execution to another location. The label or line# location must be within the same procedure.

Example:
A = 1
B = 0
Goto NextSpot
A = 5
NextSpot: ‘ This is a label
B = A
‘ B now equals 1 because the GOTO above skipped over the A = 5 statement
Goto 15
B = A + 4
10 A = 0	 ‘ 10 is a line # as is 15 on the next line
15 C = 3	 ‘ Both A and B still equal 1 because of the jump to the   line numbered 15
   

Gosub label

Gosub line#

This command will do an unconditional call, this will branch execution to another location within the Sub or Function procedure (or Start procedure). The label or line# location must be within the same procedure. Upon a Return command, program execution will continue at the command following the Gosub. Labels are designated by ending with a colon (:).

Example:

A = 5
Gosub CalcNum
‘ A now equals 26
Gosub 45
‘ A now equals 16

CalcNum:
A = A * 5 + 1
Return

45 A = A - 10	‘ 45 is the line #
Return

 

Return

This command is used in conjunction with a Gosub command. Upon a Return command, program execution will continue at the command following the Gosub.

See the GOSUB command for examples.

 

For var = startValue To endValue [Step stepValue]

This command is used in conjunction with the Next command to repeat a block of statements a specified number of times.

The Step value is the number that the var increments every time the Next statment is executed. It can be a negative number, allowing you to go from the startValue to a lower endValue. It is optional, if not specified the var will be incremented by the default value of 1.

var - This can be any valid numeric variable.

startValue - This can be any valid numeric expression that will be the first value of var.

endValue - This can be any valid numeric variable.

stepValue - This can be any valid numeric variable.

Example:

' The following will print 10 lines numbered 1 through 10
For A = 1 TO 10 
	Print A
Next A

' The following will print 4 lines numbered 1,4,7, & 10
For A = 1 TO 10 Step 3
	Print A
Next A

B = 0
For Ctr = 10 TO 30 STEP 10
	B = B + Ctr
Next Ctr
‘ B now equals 60 ( 10 + 20 + 30 )

 

Next var

This command designates the end of a For loop.

var - This can be any valid numeric variable.

See the FOR command for examples.

 

 

If logicalExpression Then command

The single line IF..Then statement will execute the command if the logicalExpression is true.

logicalExpression - This can be any valid numeric or string expression.

command - This can be any valid Visual MacStandardBasic command or user defined Sub procedure.

Examples:

A = 13
If A > 10 Then A = A+100
If A = 13 Then MySub

 

If logicalExpression Then

Else

Endif

The IF..Then, ELSE, and ENDIF commands allows conditional branching. If the logicalExpression is true, the command statements directly following will execute until the Else command(if there is one), then execution will branch to the Endif.

If the logicalExpression is false then execution will branch to the command statements following the Else command or to the ENDIF command if there is not an ELSE.

logicalExpression - This can be any valid numeric or string expression.

 

Examples:

A = 13
If A <= 10
	‘ Next line will not execute because A > 10
	A = A + 2
Else
	A = A - 3
Endif
If NOT( A = 15 )
	‘ This part will execute because A does not equal 15
	A = A + 5
Endif

 

 

Do While logicalExpression

This command is used in conjunction with the Loop command to repeat a block of statements while the logical expression is true.

logicalExpression - This can be any valid numeric or string expression.

Example:

A = 3
Do While A < 10
	‘ This should loop 4 times
	A = A + 2
Loop

 

Do Until logicalExpression

This command is used in conjunction with the Loop Statement to repeat a block of statements until the logical expression is true.

Example:

A = 5
Do Until A > 25
‘ This should loop 5 times
A = A + 5
Loop

 

Loop

This command designates the end of a Do While or Do Until loop.

See the DO WHILE and DO UNTIL commands for examples.

 

 

Select expression

This command allows branching to different locations depending on the value of the expression.

Example:

A = 3
B = 0
Select A
Case 1:
	‘ The following line will NOT execute if A = 3
	B = B + 2
Case 3:
	‘ The following line will execute if A = 3
	B = B + 32
Default:
	‘ The following line will NOT execute if A = 3
	B = B + 312
EndCase

 

Case value

The Select command will jump to the program statements following a Case statement if the expression value in the Select statement match the value in the Case statement.

value - This should be a numeric or string constant or a single variable.

Default

The Select command will jump to the program statements following the Default statement if the expression value in the Select statement does not match any of the Case statements.

 

EndCase

This command designates the end of a series of Select Case statements.

The Select command will jump to the program statements following the Endcase statement if the expression value in the Select statement does not match any of the Case statements and there is not a Default statement.

 

End

This command will end the application. It will automatically close all open windows and release memory allocated by the application.

 

ExitLoop

This command will exit the current Do/Loop. Execution will continue after the next Loop command.

Example:

A = 3
Do While A < 100
if A = 9 then ExitLoop
A = A + 2
Loop

 

ExitSub

This command will exit the current SUB procedure.

 

ExitFunction returnValue

ExitF returnValue

This command will exit the current Function procedure and return either a numeric or string value represented by returnValue. There is no difference between using either, ExitF is included to reduce typing.