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

 

Controls

This section describes controls that can be placed in forms/windows to display and receive information. The controls that are available include textboxes (with or without scrollbars), listboxes, command buttons, radio buttons, checkboxes, pictures, icons, labels, droplists, timers, and scrollbars. Visual MacStandardBasic automatically handles the operation of these controls.

There are commands to create controls 'on the fly' during runtime. Of course you can use the Visual Development Environment to create controls on forms during design time.

The terms Form and Window can be used interchangeably. A Form is just a Window that was created in the Visual Development Environment. You can use the Window command to create a Window (during runtime)without creating interactively in Visual MacStandardBasic's Visual Development Environment (design time).

When you see the parameter windowID in this manual you can give the FormName or the variable( var parameter) you used in the Window command.

Command Summary:
Button var, window#, left, top, width, height, text$, Sub
Checkbox var, window#, left, top, width, height, text$, Sub
Radio
var, window#, left, top, width, height, text$, Sub
TextBox
var, window#, left, top, width, height, text$, Sub
TextBoxRO
control#, status
TextSelect
control#, startOffset, endOffset
Label
var, window#, left, top, width, height, text$, Sub
DropList
var, window#, left, top, width, Sub
ListBox
var, window#, left, top, width, height, option, Sub
ListClear
control#
ListAdd
control#, text$
ListRemove
control#, item#
Scroll
var, window #, left, top, width, height, Sub
ScrollSet
control#, min, max, pageValue
Picture
var, window #, left, top, width, height, ResourceID, Sub
Icon
var, window #, left, top, ResourceID, Sub
Timer
var, windowID, interval, enabledFlag, Sub
CtlValue
control#, value
CtlText
control#, text$, options
CtlHilite
control#
CtlRemove
control#
CtlHide
control#
CtlShow
control#
CtlDisable
control#
CtlEnable control#
CtlSize
control#, width, height
CtlMove
control#, left, top

Function Summary:
var = TextLen ( control# )
var = TextStart ( control# )
var = TextEnd ( control# )
var$ = TextSelect ( control# )
var = ClipAvail( )
var = ListCount ( control# )
var = ListNumSel ( control# )
var$ = ListItem ( control#, item# )
var$ = ListSelect ( control#, item# )
var = CtlValue ( control# )
var$ = CtlText ( control# )
var = CtlExist ( control# )
var = CtlNum ( control# )
var$ = CtlBroder ( control#, dimension )

 

Button var, windowID, left, top, width, height, text$, Sub

This command creates a command button control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

Examples:
Dim a, WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
Button a, WinNum, 10, 10, 60, 20, "Button1", ButtonClick


Form Form1	'Display Form Window 
Button a, Form1, 10, 10, 60, 20, "Button1", ButtonClick

 

Checkbox var, windowID, left, top, width, height, text$, Sub

This command creates a checkbox control in the window specified. A checkbox can have only two values: on (1) or off (0). The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

Radio var, windowID, left, top, width, height, groupID, text$, Sub

This command creates a radio button control in the window specified. Radio buttons are different from checkboxes. Normally two or more radio buttons are grouped together by a identical groupID # . Only one of the group can be selected at a time. If another radio button of the group is selected then the previously selected button is deselected.

The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

Examples:
Dim a, b, WinNum

Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
Radio a, WinNum, 10, 10, 60, 20, 1, "Choice 1", None
Radio b, WinNum, 10, 40, 60, 20, 1, "Choice 2", None

Form Form1
Radio a, Form1, 10, 10, 60, 20, 50, "Choice 1", None
Radio b, Form1, 10, 40, 60, 20, 50, "Choice 2", None

 

TextBox var, windowID, left, top, width, height, option, text$, Sub

This command creates a textbox control in the window specified. Textbox allows the user to enter and modify text. In essence it is a small text editor.

You can use the option parameter to add an automatic vertical scrollbar and/or make the textbox read only. If the read only status is set on, the user can scan the textbox with arrow keys and mouse movement but will not be able to alter the contents of the textbox. If the status is set off, the user can modify the contents of a textbox.

Keyboard cut, copy and paste operations by the user are automatically handled for you by MacStandardBasic. A user can select and copy text from the textbox regardless of the read only status. See the Cut, Copy, Paste, and Clear commands for manual clipboard operations.

The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0, 0.

option values
0 = Normal textbox
1 = Textbox with vertical scrollbars
2 = Read only textbox
3 = Read only textbox with vertical scrollbars

TextBoxRO control_ID , status

This command sets the read only status of the specified textbox control. If the read only status is set ON ( = 1) then the user can scan the textbox with arrow keys and mouse movement but will not be able to alter the contents of the textbox. Set the status OFF ( = 0 ) to allow the user to modify the contents of the textbox.

A user can select and copy text from the textbox regardless of the read only status.

Examples:

TextBoxRO, Form1.TextBox1, 1

 

TextSelect control_ID , startOffset, endOffset

This command allows you to select a block of text of a textbox. If the startOffset and endOffset are equal then this will set the cursor position in the textbox without selecting any text. To select all the text in the textbox have startOffset equal 0 and endOffset equal 32767.

Cut

This command will cut the selected text from the current textbox and places it in the Clipboard.

 

Copy

This command will copy the selected text from the current textbox and places it in the Clipboard.

 

Paste

Inserts the current text contents of the Clipboard at the current cursor position or in place of selected text in the current textbox.

 

Clear

This command will remove the selected text from the current textbox.

 

Label var, windowID, left, top, width, height, text$, Sub

This command creates a text label control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0. The text contents of a label can not be changed by the user directly, only by the ControlText command.

DropList var, windowID, left, top, width, height, Sub

This command creates a droplist control in the window specified. A droplist control contains a list of text options added with the ListAdd command. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

Please note that the width will probably be changed depending on the text length of the longest item.

ListBox var, windowID, left, top, width, height, option, Sub

This command creates a listbox control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

ListClear control_ID

This command removes all list items from the specified droplist or listbox control.

ListAdd control_ID , text$

This command adds a list item to the specified droplist or listbox.

Example:
Dim a

a = ListAdd( Form1.ListBox1 )

ListSelect control_ID , item#

This command selects an item in a listbox.

ListDeselect control_ID , item#

This command deselects an item in a listbox.

ScrollBar var, windowID, left, top, width, height, Sub

This command creates a scrollbar control in the window specified. The location and size specified are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

ScrollSet control_ID , min, max, pageValue

This command sets the scrolling parameters of the scroll bar.

Picture var, windowID, left, top, width, height, ResourceID, Sub

This command displays a picture in the window specified. The location and size specified for the picture are local coordinates to that window. The upper left corner of the window content area is designated as 0,0. If the width and height parameters equal 0 (zero) then the picture will not be scaled but drawn it's original size.

Icon var, windowID, left, top, width, height, ResourceID, Sub

This command displays an icon picture in the window specified. The location and size specified for the icon are local coordinates to that window. The upper left corner of the window content area is designated as 0,0.

Timer var, windowID, interval, enabledFlag, Sub

You can have a Sub procedure called at timed intervals by creating a Timer control.

CtlValue control_ID, value

This command sets the current value of the control. This command can set the value of a scrollbar, the on/off status of checkboxes & radio buttons and the item selection of listboxes & droplists. For pictures and icons this is rhe resource ID.

Examples:
Dim a, b, WinNum
Window WinNum, 100, 100, 400, 300, 4, "Sample Window, None
Radio a, WinNum, 10, 10, 60, 20, 1, "Choice 1", None
Radio b, WinNum, 10, 40, 60, 20, 1, "Choice 2", None
CtlValue a, 1 ' Select first Radio button of group

' Change Resource ID of Picture do picture will change
CtlValue Picture1, 1003

 


  

CtlText control_ID, text$, options

This command sets the text in the specified control.

CtlHilite control_ID

This command places a highlight border around the specified control.

CtlRemove control_ID

This command will remove a control from a window.

CtlHide control_ID

This command will hide a control from from view. The control can be unhidden by using the ShowControl command.

CtlShow control_ID

This command will show a control hidden by a previous HideControl command.

CtlDisable control_ID

This command will disable a control. The user will not be able to select or change the control and no events will be generated. The control can be enabled by using the EnableControl command.

CtlEnable control_ID

This command will enable a control. This command is usually used to enable enable a control that was disabled using the DisableControl command.

CtlSize control_ID, width, height

This command will resize an existing control with a new width and height. Changes in width and height will only affect the right and bottom borders of the control.

CtlMove control_ID, left, top

This command moves an existing control to a new location within it’s window while maintaining the current size.

control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.

left - This is a numeric expression designating the new left x coodinate for this control.

top - This is a numeric expression designating the new top y coordinate for this control.

var = TextLen( control_ID )

This function returns a numeric value representing the total number of characters in the specified textbox, including anny CR's(carriage returns) and LF's (line feeds).

control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.

Example:
		Dim a
		
		a = TextLen( TextBox1 )

var$ = TextSelect( control_ID )

This function returns the a text string that represents the text selected in the specified textbox.

var = TextStart( control_ID )

This function returns the offset value of the selected text starting point. If it is equal to the end point (found with the TextEnd function) then this is the current cursor position.

var = TextEnd( control_ID )

This function returns the offset value of the selected text ending point. If it is equal to the the start point (found with the TextStart function) then this is the current cursor position.

 

var = ClipAvail( )

This function returns a 1 (TRUE) if there is text in the clipboard available to paste into a textbox control. If the clipboard is empty this function will return a 0 (FALSE).

 

ListRemove control_ID , item#

This command removes a list item from the specified droplist or listbox.

Example:

ListRemove DropList2, 4

 

var = ListCount( control_ID )

This function returns the number of items in a droplist or listbox.

var = ListNumSel( control_ID )

This function returns the number of selected items in a listbox.

var$ = ListItem( control_ID , item# )

This function returns a text string that represents the contents of the item# in the specified droplist or listbox control.

var = ListSelect( control_ID , item# )

This function returns a value that indicates whether an item in a listbox is selected. The value returned equals 1 if the item is selected or 0 if it is not.

 

var = CtlValue( control_ID )

This function returns the the current numeric value of the control.



Examples:
Dim a
a = CtlValue( CheckBox2 )

 

var$ = CtlText ( control_ID )

This functions returns a string that represents the text of the specified control.

control_ID - This should be the control name from a form, or the numeric variable that was used with the command when the control was created.

 

var = CtlExist( control_ID )

This function returns a true(1) / false(0) value that is tindicates that a window with the windowID has already been created.

var = CtlNum( control_ID )

This function returns a long value that is the reference number to a control that can be passed to Sub and Function procedures in long varaiables.

var = CtlBorder( control_ID , dimension )

This function returns a numeric value that represents a dimension of the specified control.

Values for dimension
1 = Return the left x screen coordinate for this control.
2 = Return the top y screen coordinate for this control.
3 = Return the width in pixels of this control.
4 = Return the height in pixels of this control.