Instructions

The table below lists each of the BASIC scripting instructions.

Instruction Name

Description

 AppActivate

Syntax:

AppActivate Title$

-or-

AppActivate TaskID

Group: Miscellaneous

Description:
Form 1: Activate the application top-level window titled Title$. If no window by that title exists then the first window with at title that starts with Title$ is activated. If no window matches then an error occurs.
Form 2: Activate the application top-level window for task TaskID. If no window for that task exists then an error occurs.

Parameter

Title$ The name shown in the title bar of the window.

TaskID This numeric value is the task identifier.

Example:

Sub Main
' make ProgMan the active application
AppActivate "Program Manager"
End Sub

Beep

Syntax:

Beep

Group: Miscellaneous

Description:
Sound the bell.

Example:

Sub Main
Beep ' beep the bell
End Sub

Call

Syntax:

Call name[(arglist)]

-or-

name [arglist]

Group: Flow Control

Description:
Evaluate the arglist and call subroutine (or function) name with those values. Sub (or function) name must be previously defined by either a Sub, Function or Property definition. If name is a function then the result is discarded. If Call is omitted and name is a subroutine then the arglist must not be enclosed in parens.

Example:

Sub Show(Title$,Value)
Debug.Print Title$;"=";Value
End Sub

Sub Main
Call Show("2000/9",2000/9) ' 222.2222222222
Show "1<2",1<2 'True
End Sub

CallByName

 Syntax:

CallByName(Obj,ProcName,CallType,[expr[,]])

Group: Flow Control

Description:
Call an Obj's method/property, ProcName, by name. Pass the exprs to the method/property.

Parameters:

Obj—Call the method/property for this object reference.

ProcName—This string value is the name of the method/property to be called.

CallType—Type of method/property call. See table below.

expr—These expressions are passed to the obj's method/property.

CallType Value Effect:

- vbMethod 1 Call or evaluate the method.

- vbGet 2 Evaluate the property's value.

- vbLet 4 Assign the property's value.

- vbSet 8 Set the property's reference.

Example:

Sub Main
On Error Resume Next
CallByName Err, "Raise", vbMethod, 1
Debug.Print CallByName(Err, "Number", vbGet) ' 1
End Sub

ChDir

Syntax:

ChDir Dir$

Group: File

Description:
Change the current directory to Dir$.

Parameter:

Dir$ This string value is the path and name of the directory.

Example:

Sub Main
ChDir "C:\"
Debug.Print CurDir$() '"C:\"
End Sub

ChDrive

Syntax:

ChDrive Drive$

Group: File

Description:
Change the current drive to Drive$.

Parameter:

Drive$ This string value is the drive letter.

Example:

Sub Main
ChDrive "B"
Debug.Print CurDir$() '"B:\"
End Sub

Close

Syntax:

Close [[#]StreamNum][,]

Group: File

Description:
Close StreamNums.

Parameter:

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros. If this is omitted then all open streams for the current macro/module are closed.

Example:

Sub Main
' read the first line of XXX and print it
Open "XXX" For Input As #1
Line Input #1,L$
Debug.Print L$
Close #1
End Sub

DDEExecute

Syntax:

DDEExecute ChanNum, Command$[, Timeout]

Group: DDE

Description:
Send the DDE Execute Command$ string via DDE ChanNum.

Parameters:

ChanNum—This is the channel number returned by the DDEInitiate function. Up to 10 channels may be used at one time.

Command$—Send this command value to the server application. The interpretation of this value is defined by the server application.

Timeout—The command will generate an error if the number of seconds specified by the timeout is exceeded before the command has completed. The default is five seconds.

Example:

Sub Main
ChanNum = DDEInitiate("PROGMAN","PROGMAN")
DDEExecute ChanNum,"[CreateGroup(XXX)]"
DDETerminate ChanNum
End Sub

DDEPoke

Syntax:

DDEPoke ChanNum, Item$, Data$[, Timeout]

Group: DDE

Description:
Poke Data$ to the Item$ via DDE ChanNum.

Parameters:

ChanNum—This is the channel number returned by the DDEInitiate function. Up to 10 channels may be used at one time.

Item$—This is the server application's item. The interpretation of this value is defined by the server application.

Data$—Send this data value to the server application. The interpretation of this value is defined by the server application.

Timeout—The command will generate an error if the number of seconds specified by the timeout is exceeded before the command has completed. The default is five seconds.

Example:

Sub Main
ChanNum = DDEInitiate("PROGMAN","PROGMAN")
DDEPoke ChanNum,"Group","XXX"
DDETerminate ChanNum
End Sub

DDETerminate

Syntax:

DDETerminate ChanNum

Group: DDE

Description:
Terminate DDE ChanNum.

Parameter:

ChanNum—This is the channel number returned by the DDEInitiate function. Up to 10 channels may be used at one time.

Example:

Sub Main
ChanNum = DDEInitiate("PROGMAN","PROGMAN")
DDEExecute ChanNum,"[CreateGroup(XXX)]"
DDETerminate ChanNum
End Sub

 DDETerminateAll

Syntax:

DDETerminateAll

Group: DDE

Description:
Terminate all open DDE channels.

Example:

Sub Main
ChanNum = DDEInitiate("PROGMAN","PROGMAN")
DDEExecute ChanNum,"[CreateGroup(XXX)]"
DDETerminateAll
End Sub

DeleteSetting

Syntax:

DeleteSetting AppName$, Section$[, Key$]

Group: Settings

Description:
Delete the settings for Key in Section in project AppName. Win16 and Win32s store settings in a.ini file named AppName. Win32 stores settings in the registration database.

Parameters:

AppName$—This string value is the name of the project which has this Section and Key.

Section$—This string value is the name of the section of the project settings.

Key$—This string value is the name of the key in the section of the project settings. If this is omitted then delete the entire section.

Example:

Sub Main
SaveSetting "MyApp","Font","Size",10
DeleteSetting "MyApp","Font","Size"
End Sub

DlgEnd

Syntax:

DlgEnd ReturnCode

Group: Dialog Function

Description:
Set the return code for the Dialog Function and close the user dialog.
This instruction/function must be called directly or indirectly from a dialogfunc.

Parameter:

ReturnCode—Return this numeric value.

Example:

Sub Main
Begin Dialog UserDialog 210,120,.DialogFunc
Text 10,10,190,15,"Please push the Close button"
OKButton 30,90,60,20
CheckBox 120,90,60,20,"&Close",.CheckBox1
End Diarlog

Dim dlg As UserDialog
Debug.Print Dialog(dlg)
End Sub

Function DialogFunc%(DlgItem$, Action%, SuppValue%)
Debug.Print "Action=";Action%
Select Case Action%
Case 1 ' Dialog box initialization
Beep
Case 2 ' Value changing or button pressed
Select Case DlgItem$
Case "CheckBox1"
DlgEnd 1000
End Select
End Select
End Function

DlgSetPicture

Syntax:

DlgSetPicture DlgItem|$, FileName, Type

Group: Dialog Function

Description:
Instruction: Set the file name for DlgItem|$.
This instruction/function must be called directly or indirectly from a dialogfunc.

Parameters:

DlgItem|$—If this is a numeric value then it is the dialog item number. The first item is 0, second is 1, etc. If this is a string value then it is the dialog item's field name.

FileName—Set the file name of DlgItem|$ to this string value.

Type—This numeric value indicates the type of bitmap used:

   0—FileName is the name of the bitmap file. If the file does not exist then "(missing picture)" is displayed.

   3—The clipboard's bitmap is displayed. Not supported.

  +16—Instead of displaying "(missing picture)" a run-time error occurs.

Example:

Sub Main
Begin Dialog UserDialog 200,120,.DialogFunc
Picture 10,10,180,75,"",0,.Picture
OKButton 30,90,60,20
PushButton 110,90,60,20,"&View"
End Dialog

Dim dlg As UserDialog
Debug.Print Dialog(dlg)
End Sub

Function DialogFunc%(DlgItem$, Action%, SuppValue%)
Debug.Print "Action=";Action%
Select Case Action%
Case 1 ' Dialog box initialization
Beep
Case 2 ' Value changing or button pressed
Select Case DlgItem$
Case "View"
FileName = GetFilePath("Bitmap","BMP")
DlgSetPicture "Picture",FileName,0
DialogFunc% = True 'do not exit the dialog
End Select
End Select
End Function

DoEvents

Syntax:

DoEvents

Group: Miscellaneous

Description:
This instruction allows other applications to process events.

Example:

Sub Main
DoEvents ' let other apps work
End Sub

End

Syntax:

End

Group: Flow Control

Description:
The end instruction causes the macro to terminate immediately. If the macro was run by another macro using the MacroRun instruction then that macro continues on the instruction following the MacroRun.

Example:

Sub DoSub
L$ = UCase$(InputBox$("Enter End:"))
If L$ = "END" Then End
Debug.Print "End was not entered."
End Sub

Sub Main
Debug.Print "Before DoSub"
DoSub
Debug.Print "After DoSub"
End Sub

Erase

Syntax:

Erase arrayvar[,...]

-or-

Erase usertypevar.elem[,...]

Group: Assignment

Description:
Reset arrayvar or user defined type array element to zero. (Dynamic arrays are reset to undimensioned arrays.) String arrays values are set to a null string. arrayvar must be declared as an array.

Declare with Dim, Private, Public or Static.

Declare as a parameter of Sub, Function or Property definition.

Example:

Sub Main

Dim X%(2)

X%(1) = 1

Erase X%

Debug.Print X%(1) ' 0

End Sub

Exit

Syntax:

Exit {All|Do|For|Function|Property|Sub|While}

Group: Flow Control

Description:
The exit instruction causes the macro to continue with out doing some or all of the remaining instructions.

All—Exit all macros.

Do—Exit the Do loop.

For—Exit the For of For Each loop.

Function—Exit the Function block. Note: This instruction clears the Err and sets Error$ to null.

Property—Exit the Property block. Note: This instruction clears the Err and sets Error$ to null.

Sub—Exit the Sub block. Note: This instruction clears the Err and sets Error$ to null.

While—Exit the While loop.

Example:

Sub Main
L$ = InputBox$("Enter Do, For, While, Sub or All:")
Debug.Print "Before DoSub"
DoSub UCase$(L$)
Debug.Print "After DoSub"
End Sub

Sub DoSub(L$)
Do
If L$ = "DO" Then Exit Do
I = I+1
Loop While I < 10
If I = 0 Then Debug.Print "Do was entered"
For I = 1 To 10
If L$ = "FOR" Then Exit For
Next I
If I = 1 Then Debug.Print "For was entered"
I = 10
While I > 0
If L$ = "WHILE" Then Exit While
I = I-1
Wend
If I = 10 Then Debug.Print "While was entered"
If L$ = "SUB" Then Exit Sub
Debug.Print "Sub was not entered."
If L$ = "ALL" Then Exit All
Debug.Print "All was not entered."
End Sub

FileCopy

Syntax:

FileCopy FromName$, ToName$

Group: File

Description:
Copy a file.

Parameters:

FromName$—This string value is the path and name of the source file. A path relative to the current directory can be used.

ToName$—This string value is the path and name of the destination file. A path relative to the current directory can be used.

Example:

Sub Main
FileCopy "C:\AUTOEXEC.BAT","C:\AUTOEXEC.BAK"
End Sub

Get

Syntax:

Get StreamNum, [RecordNum], var

Group: File

Description:
Get a variable's value from StreamNum.

Parameters:

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordNrum—For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1. If this is omitted then the current position (or record number) is used.

var—This variable value is read from the file. For a fixed length variable (like Long) the number of bytes required to restore the variable are read. For a Variant variable two bytes are read which describe its type and then the variable value is read accordingly. For a usertype variable each field is read in sequence. For an array variable each element is read in sequence. For a dynamic array variable the number of dimensions and range of each dimension is read prior to reading the array values. All binary data values are read from the file in little-endian format.
Note: When reading a string (or a dynamic array) from a Binary mode file the length (or array dimension) information is not read. The current string length determines how much string data is read. The current array dimension determines how may array elements are read.

Example:

Sub Main
Dim V As Variant
Open "SAVE_V.DAT" For Binary Access Read As #1
Get #1,, V
Close #1
End Sub

Goto

Syntax:

GoTo label

Group: Flow Control

Description:
Go to the label and continue execution from there. Only labels in the current user defined procedure are accessible.

Example:

Sub Main
X = 2
Loop:
X = X*X
If X < 100 Then GoTo Loop
Debug.Print X ' 256
End Sub

Input

Syntax:

Input [#]StreamNum, var[,...]

Group: File

Description:
Get input from StreamNum and assign it to vars. Input values are comma delimited. Leading and trailing spaces are ignored. If the first char (following the leading spaces) is a quote (") then the string is terminated by an ending quote. Special values #NULL#, #FALSE#, #TRUE#, #date# and #ERROR number# are converted to their appropriate value and data type.

Example:

Sub Main
Open "XXX" For Input As #1
Input #1,A,B,C$
Debug.Print A;B;C$
Close #1
End Sub

Kill

Syntax:

Kill Name$

Group: File

Description:
Delete the file named by Name$.

Parameter:

Name$—This string value is the path and name of the file. A path relative to the current directory can be used.

Example:

Sub Main
Kill "c:\thefile.txt"
End Sub

Let

Syntax:

[Let] var = expr

Group: Assignment

Description:
Assign the value of expr to var. The keyword Let is optional.

Example:

Sub Main
Let X = 1
X = X*2
Debug.Print X ' 2
End Sub

Line Input

Syntax:

Line Input [#]StreamNum, S$

Group: File

Description:
Get a line of input from StreamNum and assign it to S$.

Example:

Sub Main
Open "XXX" For Input As #1
Line Input #1,S$
Debug.Print S$
Close #1
End Sub

Lock

Syntax:

Lock StreamNum

-or-

Lock StreamNum, RecordNum

-or-

Lock StreamNum, [start] To end

Group: File

Description:
Form 1: Lock all of StreamNum.

Form 2: Lock a record (or byte) of StreamNum.

Form 3: Lock a range of records (or bytes) of StreamNum. If start is omitted then lock starting at the first record (or byte).

Note: Be sure to Unlock for each Lock instruction.
Note: For sequential files (Input, Output and Append) lock always affects the entire file.

Parameter

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordNum—For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1.

start—First record (or byte) in the range.

end—Last record (or byte) in the range.

Example:

Sub Main
Dim V As Variant
Open "SAVE_V.DAT" For Binary As #1
Lock #1
Get #1, 1, V
V = "Hello"
Put #1, 1, V
Unlock #1
Close #1
End Sub

LSet

Syntax:

LSet strvar = str

-or-

LSet usertypevar1 = usertypevar2

Group: Assignment

Description:
Form 1: Assign the value of str to strvar. Shorten str by removing trailing chars (or extend with blanks). The previous length strvar is maintained.

Form 2: Assign the value of usertypevar2 to usertypevar1. If usertypevar2 is longer than usertypevar1 then only copy as much as usertypevar1 can handle.

Example:

Sub Main
S$ = "123"
LSet S$ = "A"
Debug.Print ".";S$;"." '".A."
End Sub

MacroRun

Syntax:

MacroRun MacroName$[, Command$]

Group: Flow Control

Description:
Play a macro. Execution will continue at the following statement after the macro has completed.

Parameters:

MacroName$—Run the macro named by this string value.

Command$—Pass this string value as the macro's Command$ value.

Example:

Sub Main
Debug.Print "Before Demo"
MacroRun "Demo"
Debug.Print "After Demo"
End Sub

MacroRunThis

Syntax:

MacroRunThis MacroCode$

Group: Flow Control

Description:
Play the macro code. Execution will continue at the following statement after the macro code has completed. The macro code can be either a single line or a complete macro.

Parameter

MacroName$ Run the macro named by this string value.

Example:

Sub Main
Debug.Print "Before Demo"
MacroRunThis "MsgBox ""Hello"""
Debug.Print "After Demo"
End Sub

MkDir

Syntax:

MkDir Name$

Group: File

Description:
Make directory Name$.

Parameter:

Name$—This string value is the path and name of the directory. A path relative to the current directory can be used.

Example:

Sub Main
MkDir "C:\WWTEMP"
End Sub

Name

Syntax:

Name OldName$ As NewName$

Group: File

Description:
Rename file OldName$ as NewName$.

Parameters:

OldName$—This string value is the path and name of the file. A path relative to the current directory can be used.

NewName$—This is the new file name (and path). A path relative to the current directory can be used.

Example:

Sub Main
Name "c:\AUTOEXEC.BAK" As "c:\AUTOEXEC.SAV"
End Sub

On Error

Syntax:

On Error GoTo 0

-or-

On Error GoTo label

-or-

On Error Resume Next

Group: Error Handling

Description:
Form 1: Disable the error handler (default).

Form 2: Send error conditions to an error handler.

Form 3: Error conditions continue execution at the next statement.

On Error sets or disables the error handler. Each user defined procedure has its own error handler. The default is to terminate the macro on any error. The Err object's properties are set whenever an error occurs. Once an error has occurred and the error handler is executing any further errors will terminate the macro, unless the Err object has been cleared.

Note: This instruction clears the Err and sets Error$ to null.

Example:

Sub Main
On Error Resume Next
Err.Raise 1
Debug.Print "RESUMING, Err=";Err
On Error GoTo X
Err.Raise 1
Exit Sub

X: Debug.Print "Err=";Err

Err.Clear
Debug.Print "Err=";Err
Resume Next
End Sub

Open

Syntax:

Open Name$ For mode [Access access] [lock] As [#]StreamNum [Len = RecordLen]

Group: File

Description:
Open file Name$ for mode as StreamNum.

Parameters:

Name$—This string value is the path and name of the file. A path relative to the current directory can be used.

mode May be Input, Output, Append, Binary or Random.

access—May be Read, Write or Read Write.

lock—May be Shared, Lock Read, Lock Write or Lock Read Write.

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordLen—This numeric value is the record length for Random mode files. Other file modes ignore this value.

Example:

Sub Main
Open "XXX" For Output As #1
Print #1,"1,2,""Hello"""
Close #1
End Sub

Print

Syntax:

Print #StreamNum, [expr[;...][;]]

Group: File

Description:
Print the expr(s) to StreamNum. Use ; to separate expressions. A num is it automatically converted to a string before printing (just like Str$( )). If the instruction does not end with a ; then a newline is printed at the end.

Example:

Sub Main
A = 1
B = 2
C$ = "Hello"
Open "XXX" For Output As #1
Print #1,A;",";B;",""";C$;""""
Close #1
End Sub

Put

Syntax:

Put StreamNum, [RecordNum], var

Group: File

Description:
Write a variable's value to StreamNum.

Parameters:

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordNum—For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1. If this is omitted then the current position (or record number) is used.

va—This variable value is written to the file. For a fixed length variable (like Long) the number of bytes required to store the variable are written. For a Variant variable two bytes which describe its type are written and then the variable value is written accordingly. For a usertype variable each field is written in sequence. For an array variable each element is written in sequence. For a dynamic array variable the number of dimensions and range of each dimension is written prior to writing the array values. All binary data values are written to the file in little-endian format.

Note: When a writing string (or a dynamic array) to a Binary mode file the string length (or array dimension) information is not written. Only the string data or array elements are written.

Example:

Sub Main
Dim V As Variant
Open "SAVE_V.DAT" For Binary Access Write As #1
Put #1,, V
Close #1
End Sub

Randomize

Syntax:

Randomize [Seed]

Group: Math

Description:
Randomize the random number generator.

Parameter:

Seed—This numeric value sets the initial seed for the random number generator. If this value is omitted then the current time is used as the seed.

Example:

Sub Main
Randomize
Debug.Print Rnd ' 0.??????????????
End Sub

ReDim

Syntax:

ReDim [Preserve] name[type][([dim[,...]])] [As type][,...]

-or-

ReDim [Preserve] usertypevar.elem[type][([dim[,...]])] [As type][,...]

Group: Declaration

Description:
Redimension a dynamic arrayvar or user defined type array element. Use Preserve to keep the array values. Otherwise, the array values will all be reset. When using preserve only the last index of the array may change, but the number of indexes may not. (A one-dimensional array can't be redimensioned as a two-dimensional array.)

Example:

Sub Main
Dim X()
ReDim X(3)
Debug.Print UBound(X) ' 3
ReDim X(200)
Debug.Print UBound(X) ' 200
End Sub

Rem

Syntax:

Rem...

-or-

'...

Group: Miscellaneous

Description:
Both forms are comments. The Rem form is an instruction. The ' form can be used at the end of any line. All text from either ' or Rem to the end of the line is part of the comment. That text is not executed.

Example:

Sub Main
Debug.Print "Hello" ' prints to the Output tab
Rem the macro terminates at Main's End Sub
End Sub

Reset

Syntax:

Reset

Group: File

Description:
Close all open streams for the current macro/module.

Example:

Sub Main
' read the first line of XXX and print it
Open "XXX" For Input As #1
Line Input #1,L$
Debug.Print L$
Reset
End Sub

Resume

Syntax:

Resume label

-or-

Resume Next

Group: Error Handling

Description:
Form 1: Resume execution at label.

Form 2: Resume execution at the next statement.

Once an error has occurred, the error handler can use Resume to continue execution. The error handler must use Resume or Exit at the end.

Note: This instruction clears the Err and sets Error$ to null.

Example:

Sub Main
On Error GoTo X
Err.Raise 1
Debug.Print "RESUMING"
Exit Sub

X: Debug.Print "Err=";Err
Resume Next
End Sub

RmDir

Syntax:

RmDir Name$

Group: File

Description:
Remove directory Name$.

Parameter

Name$—This string value is the path and name of the directory. A path relative to the current directory can be used.

Example:

Sub Main
RmDir "C:\WWTEMP"
End Sub

RSet

Syntax:

RSet strvar = str

Group: Assignment

Description:
Assign the value of str to strvar. Shorten str by removing trailing chars (or extend with leading blanks). The previous length strvar is maintained.

Example:

Sub Main
S$ = "123"
RSet S$ = "A"
Debug.Print ".";S$;"." '". A."
End Sub

SaveSetting

Syntax:

SaveSetting AppName$, Section$, Key$, Setting

Group: Settings

Description:
Save the Setting for Key in Section in project AppName. Win16 and Win32s store settings in a.ini file named AppName. Win32 stores settings in the registration database.

Parameters:

AppName$—This string value is the name of the project which has this Section and Key.

Section$—This string value is the name of the section of the project settings.

Key$—This string value is the name of the key in the section of the project settings.

Setting—Set the key to this value. (The value is stored as a string.)

Example:

Sub Main
SaveSetting "MyApp","Font","Size",10
End Sub

Seek

Syntax:

Seek [#]StreamNum, Count

Group: File

Description:
Position StreamNum for input Count.

Parameters:

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

Count—For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1.

Example:

Sub Main
Open "XXX" For Input As #1
Line Input #1,L$
Seek #1,1 ' rewind to start of file
Input #1,A
Close #1
Debug.Print A
End Sub

SendKeys

Syntax:

SendKeys Keys$[, Wait]

Group: Miscellaneous

Description:
Send Keys$ to Windows.

Parameters:

Keys$—Send the keys in this string value to Windows. (Refer to table below.)

Wait—If this is not zero then the keys are sent before executing the next instruction. If this is omitted or zero then the keys are sent during the following instructions.

Key - Description

+ Shift modifier key: the following key is a shifted key

^ Ctrl modifier key: the following key is a control key

% Alt modifier key: the following key is an alt key

(keys) Modifiers apply to all keys

~ Send Enter key

k Send k Key (k is any single char)

K Send Shift k Key (K is any capital letter)

{special n} special key (n is an optional repeat count)

{mouse x,y} mouse key (x,y is an optional screen position)

{k} Send k Key (any single char)

{K} Send Shift k Key (any single char)

{Cancel} Send Break Key

{Esc} Send Escape Key

{Escape} Send Escape Key

{Enter} Send Enter Key

{Menu} Send Menu Key (Alt)

{Help} Send Help Key (?)

{Prtsc} Send Print Screen Key

{Print} Send

{Execute} Send ?

{Tab} Send

{Pause} Send Pause Key

{Tab} Send Tab Key

{BS} Send Back Space Key

{BkSp} Send Back Space Key

{BackSpace} Send Back Space Key

{Del} Send Delete Key

{Delete} Send Delete Key

{Ins} Send Insert Key

{Insert} Send Insert Key

{Left} Send Left Arrow Key

{Right} Send Right Arrow Key

{Up} Send Up Arrow Key

{Down} Send Down Arrow Key

{PgUp} Send Page Up Key

{PgDn} Send Page Down Key

{Home} Send Home Key

{End} Send End Key

{Select} Send ?

{Clear} Send Num Pad 5 Key

{Pad0..9} Send Num Pad 0-9 Keys

{Pad*} Send Num Pad * Key

{Pad+} Send Pad + Key

{PadEnter} Send Num Pad Enter

{Pad.} Send Num Pad. Key

{Pad-} Send Num Pad - Key

{Pad/} Send Num Pad / Key

{F1..24} Send F1 to F24 Keys

Mouse:
Mouse movement and button clicks:

{Move x,y} - move the mouse to (x,y)

{ClickLeft x,y} - move the mouse to (x,y) and click the left button. (This is the same as {DownLeft x,y}{UpLeft}.)

{DoubleClickLeft x,y} - move the mouse to (x,y) and click the left button. (This is NOT the same as {ClickLeft x,y}{ClickLeft}.)

{DownLeft x,y} - move the mouse to (x,y) and push the left button down.

{UpLeft x,y} - move the mouse to (x,y) and release the left button.

{...Middle x,y} - similarly named keys for the middle mouse button.

{...Right x,y} - similarly named keys for the right mouse button.

The x,y values are screen pixel locations, where (0,0) is in the upper-left corner. In all cases the x,y is optional. If omitted, the previous mouse position is used.

Example:

Sub Main
SendKeys "%S" ' send Alt-S (Search)
SendKeys "GoTo~~" ' send G o T o {Enter} {Enter}
End Sub

Set

Syntax:

Set objvar = objexpr

-or-

Set objvar = New objtype

Group: Assignment

Description:
Form 1: Set objvar's object reference to the object reference of objexpr.

Form 2: Set objvar's object reference to the a new instance of objtype.

The Set instruction is how object references are assigned.

Example:

Sub Main
Dim App As Object
Set App = CreateObject("WinWrap.CppDemoApplication")
App.Move 20,30 ' move icon to 20,30
Set App = Nothing
App.Quit ' run-time error (no object)
End Sub

SetAttr

Syntax:

SetAttr Name$, Attrib

Group: File

Description:
Set the attributes for file Name$. If the file does not exist then a run-time error occurs.

Parameters:

Name$—This string value is the path and name of the file. A path relative to the current directory can be used.

Attrib—Set the file's attributes to this numeric value.

Example:

Sub Main
Attrib = GetAttr("XXX")
SetAttr "XXX",1 ' readonly
Debug.Print GetAttr("XXX") ' 1
SetAttr "XXX",Attrib
End Sub

Stop

Syntax:

Stop

Group: Flow Control

Description:
Pause execution. If execution is resumed then it starts at the next instruction. Use End to terminate the macro completely.

Example:

Sub Main
For I = 1 To 10
Debug.Print I
If I = 3 Then Stop
Next I

End Sub

Unlock

Syntax:

Unlock StreamNum

-or-

Unlock StreamNum, RecordNum

-or-

Unlock StreamNum, [start] To end

Group: File

Description:
Form 1: Unlock all of StreamNum.

Form 2: Unlock a record (or byte) of StreamNum.

Form 3: Unlock a range of records (or bytes) of StreamNum. If start is omitted then unlock starting at the first record (or byte).

Note: For sequential files (Input, Output and Append) unlock always affects the entire file.

Parameters:

StreamNum—Streams 1 through 255 are private to each macro. Streams 256 through 511 are shared by all macros.

RecordNum—For Random mode files this is the record number. The first record is 1. Otherwise, it is the byte position. The first byte is 1.

start—First record (or byte) in the range.

end—Last record (or byte) in the range.

Example:

Sub Main
Dim V As Variant
Open "SAVE_V.DAT" For Binary As #1
Lock #1
Get #1, 1, V
V = "Hello"
Put #1, 1, V
Unlock #1
Close #1
End Sub

 Wait

Syntax:

Wait Delay

Group: Miscellaneous

Description:
Wait for Delay seconds.

Example:

Sub Main
Wait 5 ' wait for 5 seconds
End Sub

Write

Syntax:

Write #StreamNum, expr[,...]

Group: File

Description:
Write's expr(s) to StreamNum. String values are quoted. Null values are written as #NULL#. Boolean values are written as #FALSE# or #TRUE#. Date values are written as #date#. Error codes are written as #ERROR number#.

Example:

Sub Main
A = 1
B = 2
C$ = "Hello"
Open "XXX" For Output As #1
Write #1,A,B,C$
Close #1
End Sub