16.11.2012 Views

Dragon NaturallySpeaking Version 9 System ... - Image Management

Dragon NaturallySpeaking Version 9 System ... - Image Management

Dragon NaturallySpeaking Version 9 System ... - Image Management

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1<br />

Copyright © 2006 Nuance Communications, Inc. All rights reserved.<br />

Note: For the latest <strong>System</strong> Administration information, see<br />

http://support.nuance.com/downloads/<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

<strong>Version</strong> 9<br />

<strong>System</strong> Administration Guide


Contents<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> <strong>System</strong> Administration Guide ...........................................................10<br />

Overview ........................................................................................................................................ 10<br />

Installation and Upgrade .......................................................................................................11<br />

Recommended <strong>System</strong> Requirements for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> ...................................................... 11<br />

Coexistence with <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition.............................................................. 11<br />

Upgrading from a previous version..................................................................................................... 12<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Installation ................................................................................................ 12<br />

Modifying settings for all users .......................................................................................................... 14<br />

MSI Installation Options.................................................................................................................... 14<br />

Windows Installer (MSI) options ........................................................................................................ 15<br />

MSI options specific to <strong>NaturallySpeaking</strong> ........................................................................................... 16<br />

InstallShield (setup.exe) options........................................................................................................ 23<br />

Sample Command line...................................................................................................................... 24<br />

Using the User Upgrade Wizard to upgrade multiple users..................................................................... 25<br />

Upgrading Users with Custom Vocabularies ......................................................................................... 28<br />

<strong>Version</strong> 9 File Structure .................................................................................................................... 29<br />

Cleaning up after uninstalling <strong>Dragon</strong> <strong>NaturallySpeaking</strong>....................................................................... 30<br />

Command line interface .................................................................................................................... 31<br />

Setting up Roaming Users .....................................................................................................32<br />

About the Roaming User feature ........................................................................................................ 32<br />

Setting up the Roaming User feature.................................................................................................. 33<br />

Roaming User Network Location......................................................................................................... 37<br />

Internet Roaming User Guidelines ...................................................................................................... 38<br />

Creating a Roaming User .................................................................................................................. 40<br />

Using multiple dictation sources with a single user ............................................................................... 42<br />

Running the Acoustic and Language Model Optimizer for Roaming Users................................................. 43<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Data Distribution Tool .....................................................................43<br />

Overview ........................................................................................................................................ 43<br />

Using the Data Distribution Tool ........................................................................................................ 44<br />

Data Distribution Tool : Add and removing custom words ..................................................................... 45<br />

Data Distribution Tool : Adding and removing vocabularies ................................................................... 46<br />

Data Distribution Tool: Adding and removing custom commands ........................................................... 47<br />

Nsadmin command line..................................................................................................................... 48<br />

Using nsadmin................................................................................................................................. 49<br />

nsadmin: Adding custom words ......................................................................................................... 50<br />

nsadmin: Adding and Deleting Custom Vocabularies............................................................................. 51<br />

nsadmin: Adding Custom Commands .................................................................................................53<br />

Vocabulary Tool ...................................................................................................................54<br />

<strong>Dragon</strong> Vocabulary Tool (Voctool) ...................................................................................................... 54<br />

<strong>Dragon</strong> Vocabulary Tool: Overview..................................................................................................... 54<br />

<strong>Dragon</strong> Vocabulary Tool: Choosing Documents .................................................................................... 55<br />

<strong>Dragon</strong> Vocabulary Tool: Choosing Word Lists .....................................................................................56<br />

<strong>Dragon</strong> Vocabulary Tool: Analyzing Settings........................................................................................ 57<br />

<strong>Dragon</strong> Vocabulary Tool: Analyzing Files ............................................................................................. 58<br />

<strong>Dragon</strong> Vocabulary Tool: Previewing New Words.................................................................................. 58<br />

<strong>Dragon</strong> Vocabulary Tool: Training Added Words................................................................................... 59<br />

<strong>Dragon</strong> Vocabulary Tool: Language Model Building............................................................................... 60<br />

<strong>Dragon</strong> Vocabulary Tool: Summary Screen ......................................................................................... 61<br />

Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> with Citrix .............................................................................62<br />

Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix environment (overview)....................................................... 62<br />

Installing and publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server ................................................. 62<br />

Creating Policies for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server........................................................ 64<br />

Making Published Applications Work together ...................................................................................... 65<br />

2


Setting Up the Program Neighborhood on Citrix clients ......................................................................... 66<br />

Starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from a Citrix client ......................................................................... 67<br />

The Convert XML to DAT tool .................................................................................................69<br />

Using the Convert XML to DAT tool..................................................................................................... 69<br />

Advanced Scripting Commands ..............................................................................................70<br />

The MyCommands Editor: Advanced Scripting dialog box...................................................................... 70<br />

Using ActiveX Components................................................................................................................ 72<br />

The Script editing window ................................................................................................................. 73<br />

The Advanced Scripting menu ........................................................................................................... 74<br />

The Advanced Scripting Editor toolbar ................................................................................................ 75<br />

The Immediate window..................................................................................................................... 76<br />

The Watch window ........................................................................................................................... 77<br />

The Stack window ............................................................................................................................ 79<br />

Object and Proc lists......................................................................................................................... 80<br />

The Break bar.................................................................................................................................. 80<br />

The Edit area................................................................................................................................... 81<br />

The Status bar................................................................................................................................. 82<br />

The Object Browser.......................................................................................................................... 82<br />

The References dialog box ................................................................................................................ 83<br />

The UserDialog Editor dialog box........................................................................................................ 84<br />

Advanced Scripting Basic Language.................................................................................................... 86<br />

Objects Overview............................................................................................................................. 86<br />

Operators ....................................................................................................................................... 87<br />

All Functions by Groups .................................................................................................................... 88<br />

Assignment Group............................................................................................................................ 89<br />

Constant Group ............................................................................................................................... 90<br />

Conversion Group ............................................................................................................................ 90<br />

Data Type Group ............................................................................................................................. 90<br />

DDE Group...................................................................................................................................... 90<br />

Declaration Group ............................................................................................................................ 90<br />

Dialog Function Group ...................................................................................................................... 90<br />

Error Handling Group........................................................................................................................ 90<br />

File Group ....................................................................................................................................... 91<br />

Flow Control Group .......................................................................................................................... 91<br />

Math Group ..................................................................................................................................... 91<br />

Miscellaneous Group......................................................................................................................... 91<br />

Object Group................................................................................................................................... 91<br />

Operator Group ............................................................................................................................... 91<br />

Settings Group ................................................................................................................................ 91<br />

String Group ................................................................................................................................... 92<br />

Time/Date Group ............................................................................................................................. 92<br />

User Dialog Group............................................................................................................................ 92<br />

User Input Group ............................................................................................................................. 92<br />

Variable Info Group .......................................................................................................................... 92<br />

Class Module ................................................................................................................................... 92<br />

Code Module ................................................................................................................................... 94<br />

Object Module ................................................................................................................................. 94<br />

Any Data Type................................................................................................................................. 95<br />

Boolean Data Type ........................................................................................................................... 95<br />

Byte Data Type................................................................................................................................ 96<br />

Currency Data Type ......................................................................................................................... 96<br />

Date Data Type ............................................................................................................................... 96<br />

Decimal Data Type........................................................................................................................... 96<br />

Double Data Type ............................................................................................................................ 97<br />

Integer Data Type............................................................................................................................ 97<br />

Long Data Type ............................................................................................................................... 97<br />

Object Data Type ............................................................................................................................. 97<br />

PortInt Data Type ............................................................................................................................ 98<br />

Single Data Type ............................................................................................................................. 98<br />

3


4<br />

String Data Type.............................................................................................................................. 98<br />

String*n Data Type .......................................................................................................................... 99<br />

UserDialog Data Type ....................................................................................................................... 99<br />

Variant Data Type ............................................................................................................................ 99<br />

Usertype definition........................................................................................................................... 99<br />

Empty Keyword ............................................................................................................................... 99<br />

False Keyword ............................................................................................................................... 100<br />

Nothing Keyword ........................................................................................................................... 100<br />

Null Keyword................................................................................................................................. 100<br />

True Keyword ................................................................................................................................ 101<br />

Win16 Keyword ............................................................................................................................. 101<br />

Win32 Keyword ............................................................................................................................. 101<br />

Friend Keyword ............................................................................................................................. 101<br />

Main Sub ...................................................................................................................................... 102<br />

Object_Initialize Sub ...................................................................................................................... 102<br />

Object_Terminate Sub .................................................................................................................... 102<br />

Set Instruction .............................................................................................................................. 103<br />

Private Keyword ............................................................................................................................ 103<br />

Public Keyword .............................................................................................................................. 104<br />

AboutWinWrapBasic Instruction ....................................................................................................... 104<br />

Abs Function ................................................................................................................................. 104<br />

AppActivate Instruction .................................................................................................................. 105<br />

arglist definition............................................................................................................................. 105<br />

Array Function............................................................................................................................... 106<br />

Array variable definition.................................................................................................................. 106<br />

As [New] type definition ................................................................................................................. 106<br />

Asc Function.................................................................................................................................. 106<br />

As type definition........................................................................................................................... 107<br />

Atn Function.................................................................................................................................. 107<br />

Attribute definition ......................................................................................................................... 108<br />

Attribute Definition/Statement......................................................................................................... 108<br />

Beep Instruction ............................................................................................................................ 109<br />

Begin Dialog Definition ................................................................................................................... 109<br />

Big-endian definition ...................................................................................................................... 110<br />

Call Instruction .............................................................................................................................. 111<br />

CallByName Instruction .................................................................................................................. 111<br />

CallersLine Function ....................................................................................................................... 112<br />

CancelButton Dialog Item Definition ................................................................................................. 112<br />

CBool Function .............................................................................................................................. 113<br />

CByte Function .............................................................................................................................. 114<br />

CCur Function................................................................................................................................ 114<br />

CDate Function .............................................................................................................................. 114<br />

CDbl Function................................................................................................................................ 115<br />

CDec Function ............................................................................................................................... 115<br />

charlist definition ........................................................................................................................... 116<br />

ChDir Instruction ........................................................................................................................... 116<br />

ChDrive Instruction ........................................................................................................................ 117<br />

CheckBox Dialog Item Definition ...................................................................................................... 117<br />

Choose Function ............................................................................................................................ 118<br />

Chr$ Function................................................................................................................................ 119<br />

Chr$ Function................................................................................................................................ 119<br />

Chr$ Function................................................................................................................................ 120<br />

CInt Function ................................................................................................................................ 120<br />

Class_Initialize Sub ........................................................................................................................ 121<br />

Class_Terminate Sub...................................................................................................................... 121<br />

Class Module ................................................................................................................................. 121<br />

Clipboard Instruction/Function......................................................................................................... 123<br />

CLng Function ............................................................................................................................... 123<br />

Close Instruction............................................................................................................................ 124


5<br />

ComboBox Dialog Item Definition..................................................................................................... 124<br />

Command$ Function ...................................................................................................................... 125<br />

condexpr definition ........................................................................................................................ 126<br />

Const Definition ............................................................................................................................. 126<br />

Cos Function ................................................................................................................................. 126<br />

CreateObject Function .................................................................................................................... 127<br />

CSng Function ............................................................................................................................... 127<br />

CStr Function ................................................................................................................................ 128<br />

CurDir$ Function............................................................................................................................ 128<br />

CVar Function................................................................................................................................ 129<br />

CVErr Function .............................................................................................................................. 129<br />

Date Function................................................................................................................................ 130<br />

DateAdd Function .......................................................................................................................... 130<br />

DateDiff Function ........................................................................................................................... 131<br />

dateexpr definition ......................................................................................................................... 132<br />

DatePart Function .......................................................................................................................... 132<br />

DateSerial Function ........................................................................................................................ 132<br />

DateValue Function ........................................................................................................................ 133<br />

Day Function ................................................................................................................................. 133<br />

DDEExecute Instruction .................................................................................................................. 134<br />

DDEInitiate Function ...................................................................................................................... 135<br />

DDEPoke Instruction ...................................................................................................................... 135<br />

DDERequest$ Function ................................................................................................................... 136<br />

DDETerminate Instruction ............................................................................................................... 136<br />

DDETerminateAll Instruction ........................................................................................................... 137<br />

Debug Object ................................................................................................................................ 137<br />

Declare Definition .......................................................................................................................... 138<br />

Def Definition ................................................................................................................................ 139<br />

DeleteSetting Instruction ................................................................................................................ 140<br />

dialogfunc definition ....................................................................................................................... 141<br />

DialogFunc Prototype...................................................................................................................... 141<br />

Dialog Instruction/Function ............................................................................................................. 142<br />

Dim definition................................................................................................................................ 143<br />

Dim Definition ............................................................................................................................... 143<br />

Dir$ Function................................................................................................................................. 144<br />

DlgControlId Function..................................................................................................................... 145<br />

DlgCount Function.......................................................................................................................... 146<br />

DlgEnd Instruction ......................................................................................................................... 146<br />

DlgEnable Instruction/Function ........................................................................................................ 147<br />

DlgFocus Instruction/Function ......................................................................................................... 148<br />

DlgListBoxArray Instruction/Function................................................................................................ 149<br />

DlgName Function.......................................................................................................................... 150<br />

DlgNumber Function....................................................................................................................... 151<br />

DlgSetPicture Instruction ................................................................................................................ 152<br />

DlgText Instruction/Function ........................................................................................................... 153<br />

DlgType Function ........................................................................................................................... 154<br />

DlgValue Instruction/Function.......................................................................................................... 154<br />

dlgvar definition............................................................................................................................. 156<br />

DlgVisible Instruction/Function ........................................................................................................ 156<br />

Do Statement................................................................................................................................ 157<br />

DoEvents Instruction ...................................................................................................................... 158<br />

DropListBox Dialog Item Definition................................................................................................... 158<br />

End Instruction .............................................................................................................................. 159<br />

Enum Definition ............................................................................................................................. 160<br />

Environ Instruction/Function ........................................................................................................... 160<br />

EOF Function ................................................................................................................................. 161<br />

Erase Instruction ........................................................................................................................... 161<br />

Err Object ..................................................................................................................................... 162<br />

Error Instruction/Function ............................................................................................................... 163


6<br />

Eval Function................................................................................................................................. 164<br />

Exit Instruction.............................................................................................................................. 164<br />

Exp Function ................................................................................................................................. 165<br />

Expr definition ............................................................................................................................... 166<br />

Field definition............................................................................................................................... 166<br />

FileAttr Function ............................................................................................................................ 166<br />

FileCopy Instruction ....................................................................................................................... 167<br />

FileDateTime Function .................................................................................................................... 167<br />

FileLen Function............................................................................................................................. 168<br />

Fix Function .................................................................................................................................. 168<br />

For Statement ............................................................................................................................... 169<br />

For Each Statement........................................................................................................................ 169<br />

Format$ Function........................................................................................................................... 170<br />

FreeFile Function............................................................................................................................ 171<br />

Friend Keyword ............................................................................................................................. 171<br />

Function Definition ......................................................................................................................... 171<br />

Get Instruction .............................................................................................................................. 172<br />

GetAllSettings Function................................................................................................................... 173<br />

GetAttr Function ............................................................................................................................ 174<br />

GetFilePath$ Function..................................................................................................................... 174<br />

GetObject Function ........................................................................................................................ 175<br />

GetSetting Function........................................................................................................................ 175<br />

Goto Instruction ............................................................................................................................ 176<br />

GroupBox Dialog Item Definition...................................................................................................... 176<br />

Hex$ Function ............................................................................................................................... 177<br />

Hour Function................................................................................................................................ 178<br />

If Statement.................................................................................................................................. 178<br />

IIf Function ................................................................................................................................... 179<br />

Input Instruction............................................................................................................................ 180<br />

Input$ Function ............................................................................................................................. 180<br />

InputBox$ Function ........................................................................................................................ 181<br />

InStr Function ............................................................................................................................... 181<br />

InStr Function ............................................................................................................................... 182<br />

InStrRev Function .......................................................................................................................... 182<br />

Instruction definition ...................................................................................................................... 183<br />

Int Function .................................................................................................................................. 183<br />

Is Operator ................................................................................................................................... 184<br />

IsArray Function ............................................................................................................................ 184<br />

IsDate Function ............................................................................................................................. 185<br />

IsEmpty Function ........................................................................................................................... 185<br />

IsError Function............................................................................................................................. 186<br />

IsMissing Function.......................................................................................................................... 186<br />

IsNumeric Function ........................................................................................................................ 187<br />

IsNull Function .............................................................................................................................. 188<br />

IsObject Function........................................................................................................................... 188<br />

KeyName Function ......................................................................................................................... 189<br />

Kill Instruction ............................................................................................................................... 189<br />

Label definition .............................................................................................................................. 190<br />

LBound Function ............................................................................................................................ 190<br />

LCase$ Function ............................................................................................................................ 191<br />

Left$ Function ............................................................................................................................... 191<br />

Left$ Function ............................................................................................................................... 192<br />

Len Function ................................................................................................................................. 192<br />

Len Function ................................................................................................................................. 193<br />

Let Instruction............................................................................................................................... 193<br />

Like Operator ................................................................................................................................ 194<br />

Line Input Instruction ..................................................................................................................... 194<br />

Line Input Instruction ..................................................................................................................... 195<br />

ListBox Dialog Item Definition ......................................................................................................... 195


7<br />

Little-endian definition.................................................................................................................... 196<br />

Loc Function.................................................................................................................................. 197<br />

Lock Instruction............................................................................................................................. 197<br />

LOF Function ................................................................................................................................. 198<br />

Log Function ................................................................................................................................. 198<br />

LSet Instruction ............................................................................................................................. 199<br />

LTrim$ Function............................................................................................................................. 200<br />

Macro definition ............................................................................................................................. 200<br />

MacroDir$ Function ........................................................................................................................ 200<br />

MacroRun Instruction ..................................................................................................................... 201<br />

MacroRunThis Instruction................................................................................................................ 201<br />

Me Object ..................................................................................................................................... 202<br />

Method definition ........................................................................................................................... 202<br />

Mid$ Function/Assignment .............................................................................................................. 202<br />

Mid$ Function/Assignment .............................................................................................................. 203<br />

Minute Function ............................................................................................................................. 204<br />

MkDir Instruction ........................................................................................................................... 205<br />

Module definition ........................................................................................................................... 205<br />

Month Function.............................................................................................................................. 205<br />

MonthName Function...................................................................................................................... 206<br />

MsgBox Instruction/Function ........................................................................................................... 206<br />

MultiListBox Dialog Item Definition................................................................................................... 208<br />

Name definition ............................................................................................................................. 209<br />

Name Instruction ........................................................................................................................... 209<br />

Now Function ................................................................................................................................ 209<br />

Num definition............................................................................................................................... 210<br />

Numvar definition .......................................................................................................................... 210<br />

Objexpr definition .......................................................................................................................... 210<br />

Objtype definition .......................................................................................................................... 210<br />

Objvar definition ............................................................................................................................ 210<br />

Oct$ Function ................................................................................................................................ 211<br />

OKButton Dialog Item Definition ...................................................................................................... 211<br />

On Error Instruction ....................................................................................................................... 212<br />

Open Instruction............................................................................................................................ 213<br />

Option Definition............................................................................................................................ 213<br />

OptionButton Dialog Item Definition ................................................................................................. 214<br />

OptionGroup Dialog Item Definition.................................................................................................. 215<br />

Param definition ............................................................................................................................ 216<br />

Picture Dialog Item Definition .......................................................................................................... 216<br />

Precedence definition ..................................................................................................................... 217<br />

Print Instruction............................................................................................................................. 217<br />

Private Definition ........................................................................................................................... 218<br />

Procedure definition ....................................................................................................................... 219<br />

Property definition ......................................................................................................................... 219<br />

Property Definition ......................................................................................................................... 219<br />

Public Definition............................................................................................................................. 220<br />

PushButton Dialog Item Definition.................................................................................................... 221<br />

Put Instruction............................................................................................................................... 221<br />

QBColor Function ........................................................................................................................... 222<br />

Randomize Instruction.................................................................................................................... 223<br />

ReDim Instruction .......................................................................................................................... 223<br />

Reference Comment....................................................................................................................... 224<br />

Rem Instruction............................................................................................................................. 225<br />

Replace$ Function.......................................................................................................................... 225<br />

Reset Instruction ........................................................................................................................... 226<br />

Resume Instruction ........................................................................................................................ 226<br />

RGB Function ................................................................................................................................ 227<br />

Right$ Function ............................................................................................................................. 227<br />

Right$ Function ............................................................................................................................. 228


8<br />

RmDir Instruction .......................................................................................................................... 228<br />

Rnd Function ................................................................................................................................. 229<br />

Round Function.............................................................................................................................. 229<br />

RSet Instruction............................................................................................................................. 230<br />

RTrim$ Function ............................................................................................................................ 230<br />

SaveSetting Instruction .................................................................................................................. 231<br />

Second Function ............................................................................................................................ 231<br />

Seek Function................................................................................................................................ 232<br />

Seek Instruction ............................................................................................................................ 232<br />

Select Case Statement ................................................................................................................... 233<br />

Select Case Statement ................................................................................................................... 234<br />

SendKeys Instruction ..................................................................................................................... 235<br />

Set Instruction .............................................................................................................................. 237<br />

SetAttr Instruction ......................................................................................................................... 237<br />

Sgn Function ................................................................................................................................. 238<br />

Shell Function................................................................................................................................ 238<br />

ShowPopupMenu Function............................................................................................................... 239<br />

Sin Function .................................................................................................................................. 240<br />

Space$ Function ............................................................................................................................ 240<br />

Sqr Function.................................................................................................................................. 241<br />

Statement definition....................................................................................................................... 241<br />

Static Definition ............................................................................................................................. 241<br />

Stop Instruction............................................................................................................................. 242<br />

Str definition ................................................................................................................................. 242<br />

Str$ Function ................................................................................................................................ 243<br />

Strarray definition.......................................................................................................................... 243<br />

StrConv$ Function ......................................................................................................................... 243<br />

String$ Function ............................................................................................................................ 244<br />

StrReverse$ Function ..................................................................................................................... 245<br />

Strvar definition............................................................................................................................. 245<br />

Sub Definition................................................................................................................................ 245<br />

Tan Function ................................................................................................................................. 246<br />

Text Dialog Item Definition ............................................................................................................. 246<br />

TextBox Dialog Item Definition ........................................................................................................ 247<br />

Text Dialog Item Definition ............................................................................................................. 248<br />

Time Function................................................................................................................................ 249<br />

Timer Function .............................................................................................................................. 249<br />

TimeSerial Function........................................................................................................................ 250<br />

TimeValue Function........................................................................................................................ 250<br />

Trim$ Function .............................................................................................................................. 251<br />

Type definition............................................................................................................................... 251<br />

Type Definition .............................................................................................................................. 252<br />

TypeName Function........................................................................................................................ 252<br />

UBound Function............................................................................................................................ 253<br />

UCase$ Function ............................................................................................................................ 254<br />

Unlock Instruction.......................................................................................................................... 254<br />

Userenum definition ....................................................................................................................... 255<br />

Usertypevar definition .................................................................................................................... 255<br />

Uses Comment .............................................................................................................................. 256<br />

Val Function .................................................................................................................................. 256<br />

Var definition................................................................................................................................. 257<br />

Variantvar definition....................................................................................................................... 257<br />

VarType Function ........................................................................................................................... 257<br />

Wait Instruction............................................................................................................................. 258<br />

Weekday Function.......................................................................................................................... 259<br />

WeekdayName Function.................................................................................................................. 259<br />

While Statement ............................................................................................................................ 260<br />

With Statement ............................................................................................................................. 260<br />

WithEvents Definition ..................................................................................................................... 261


Write Instruction............................................................................................................................ 261<br />

Year Function ................................................................................................................................ 262<br />

Objects Overview........................................................................................................................... 262<br />

Format Predefined Date .................................................................................................................. 263<br />

Format Predefined Number ............................................................................................................. 263<br />

Format User Defined Date............................................................................................................... 264<br />

Format User Defined Number .......................................................................................................... 265<br />

Format User Defined Text ............................................................................................................... 266<br />

Error List ...................................................................................................................................... 266<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> scripting language extensions quick reference.............................................. 268<br />

Guidelines for writing scripts ........................................................................................................... 269<br />

List Variables................................................................................................................................. 269<br />

ActiveControlPick ........................................................................................................................... 270<br />

ActiveMenuPick.............................................................................................................................. 271<br />

AppBringUp................................................................................................................................... 272<br />

AppSwapWith ................................................................................................................................ 273<br />

Beep ............................................................................................................................................ 274<br />

ButtonClick ................................................................................................................................... 274<br />

ClearDesktop................................................................................................................................. 275<br />

ControlPick.................................................................................................................................... 275<br />

DdeExecute................................................................................................................................... 276<br />

DdePoke ....................................................................................................................................... 276<br />

DllCall .......................................................................................................................................... 277<br />

DragToPoint .................................................................................................................................. 278<br />

GetState ....................................................................................................................................... 279<br />

GoToSleep .................................................................................................................................... 279<br />

HeardWord.................................................................................................................................... 279<br />

HTMLHelp ..................................................................................................................................... 280<br />

MenuCancel................................................................................................................................... 282<br />

MenuPick ...................................................................................................................................... 282<br />

MouseGrid..................................................................................................................................... 282<br />

MsgBoxConfirm ............................................................................................................................. 283<br />

MyCommandsActiveState................................................................................................................ 284<br />

PlaySound..................................................................................................................................... 285<br />

PromptValue Function..................................................................................................................... 285<br />

RememberPoint ............................................................................................................................. 286<br />

RunScriptFile ................................................................................................................................. 287<br />

Send<strong>Dragon</strong>Keys ........................................................................................................................... 287<br />

Send<strong>System</strong>Keys ........................................................................................................................... 288<br />

SetMicrophone............................................................................................................................... 289<br />

SetMousePosition........................................................................................................................... 289<br />

SetNaturalText .............................................................................................................................. 290<br />

SetState ....................................................................................................................................... 291<br />

ShellExecute ................................................................................................................................. 291<br />

TTSPlayString................................................................................................................................ 292<br />

Wait ............................................................................................................................................. 293<br />

WaitForWindow.............................................................................................................................. 293<br />

WakeUp........................................................................................................................................ 294<br />

WinHelp........................................................................................................................................ 295<br />

Key names for Send<strong>Dragon</strong>Keys ...................................................................................................... 295<br />

Windows shortcut keys ................................................................................................................... 297<br />

Error messages for scripts............................................................................................................... 297<br />

Structured Commands ........................................................................................................ 298<br />

About Structured Commands........................................................................................................... 298<br />

Structured Commands Samples ....................................................................................................... 298<br />

Importing Structured Commands ..................................................................................................... 300<br />

9


<strong>Dragon</strong> <strong>NaturallySpeaking</strong> <strong>System</strong> Administration Guide<br />

Overview<br />

Note: For the latest <strong>System</strong> Administration information,<br />

see<br />

http://support.nuance.com/downloads/<br />

The <strong>Dragon</strong> <strong>NaturallySpeaking</strong> <strong>System</strong> Administration Guide contains the following information:<br />

10<br />

• Installation and upgrade<br />

o <strong>System</strong> Requirements<br />

o Coexistence with <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition<br />

o Upgrading from a previous version<br />

o <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Installation<br />

o Modifying settings for all users<br />

o MSI Installation Options<br />

o Using the User Upgrade Wizard to upgrade multiple users<br />

o Upgrading Users with Custom Vocabularies<br />

o <strong>Version</strong> 9 File Structure<br />

o Cleaning up after uninstalling <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

o Command line interface<br />

• Setting up Roaming Users<br />

o About the Roaming User feature<br />

o Setting up the Roaming User feature<br />

o Roaming User Network Location<br />

o Internet Roaming User Guidelines<br />

o Creating a Roaming User<br />

o Using multiple dictation sources with a single user<br />

o Running the Acoustic and Language Model Optimizer for Roaming Users<br />

• Using the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Data Distribution Tool<br />

• Using the Nsadmin Wizard<br />

• Using the Vocabulary Tool


11<br />

• Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> with Citrix<br />

o Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix environment<br />

o Installing and publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

o Creating Policies for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

o Making Published Applications Work together<br />

o Setting Up the Program Neighborhood on Citrix clients<br />

o Starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from a Citrix client<br />

• Using the Convert XML to DAT tool<br />

Installation and Upgrade<br />

Recommended <strong>System</strong> Requirements for <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

� CPU speed 1GHz or greater. Recommended: 2.4 GHz<br />

� 1GB RAM (512 MB free minimum)<br />

� Minimum of 500MB of free hard disk space for a custom Installation where you install only the program files<br />

and 1 set of speech files. Installations can range from 800 MB (US English Standard) to 2.5 GB (US English<br />

Medical).<br />

� Windows 2000 Service Pack 4 or higher, Windows Server 2003, Windows XP Pro or Windows XP Home (SP1 or<br />

SP2).<br />

� Creative Labs® Sound Blaster® 16 or equivalent sound card supporting 16-bit recording<br />

� Microsoft® Internet Explorer 5 or higher (free download available at www.microsoft.com)<br />

� An internet connection for product activation.<br />

� CD-ROM drive (required for installation)<br />

� Nuance-approved noise-canceling headset microphone<br />

� Speakers (required for playback of recorded speech and text-to-speech features)<br />

Coexistence with <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition<br />

You can install <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition 9 on the same machine where <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> 9 is installed.<br />

In addition, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> 9 and <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition 9 can share<br />

vocabularies and users.<br />

You can only run one product at the same time. For example, if you are running <strong>Dragon</strong> <strong>NaturallySpeaking</strong> you<br />

cannot run any of the SDK Client tools or samples.


Notes:<br />

Coexistence with <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition <strong>Version</strong> 8 is not supported.<br />

Upgrading from a previous version<br />

12<br />

You can upgrade from <strong>Dragon</strong> <strong>NaturallySpeaking</strong> <strong>Version</strong>s 7 and 8.<br />

During an upgrade, the V9 upgrade procedure will ask you to:<br />

� Remove the previous <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation. If you choose not to remove the previous<br />

installation, you cannot continue to upgrade. Removing <strong>Version</strong> 7 or 8 will not remove your V7 or 8 speech<br />

files and vocabularies.<br />

� Migrate your existing user files and vocabularies to <strong>Version</strong> 9. If you choose not to upgrade your user files and<br />

vocabularies during the upgrade, you can do so at a later time by running the <strong>Version</strong> 9 Upgrade Tool.<br />

Once V9 is installed, your previous version will no longer be functional.<br />

Note: The user files from previous versions remain untouched in case you decide to later reinstall the previous<br />

version.<br />

Edition considerations<br />

You must upgrade to the same edition or higher and to the same language.<br />

For example, if you started with <strong>Version</strong> 8 German/English and you upgrade to <strong>Version</strong> 9 English only, your<br />

<strong>Version</strong> 8 German users will not be upgraded. Upgrading to <strong>Version</strong> 9 German/English will upgrade both your<br />

German and English users. After upgrading, you can install other <strong>Version</strong> 9 languages.<br />

Directory Changes<br />

For information on changes to the directory structure when upgrading from <strong>Version</strong> 7 or 8, see <strong>Version</strong> 9 File<br />

Structure.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Installation<br />

This topic describes the basics steps for installing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on a single machine.<br />

For complete a complete description of installing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on a single machine., please see<br />

the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> User's Guide.<br />

Note<br />

� You must have Administrator rights to install or uninstall <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on Windows 2000 and<br />

Windows XP.


13<br />

For Windows 2000 and Windows XP Professional systems with limited user accounts (users with restricted<br />

privileges), if the administrator wants to create a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> user for a limited user, the<br />

administrator must log on as the limited user. If an administrator creates a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> user for<br />

a limited user account from an administrator account, the limited user account will not be able to access that<br />

user. Administrator rights are not required to create a user or use the software after installation. These<br />

restrictions also apply for an upgrade installation.<br />

� If you decide not to install some <strong>Dragon</strong> <strong>NaturallySpeaking</strong> components by selecting Custom installation, you<br />

can install them later by running the Setup program again and choosing Modify.<br />

Installing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on a single machine<br />

To install <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

1. Insert the first <strong>Dragon</strong> <strong>NaturallySpeaking</strong> CD into your CD-ROM drive.<br />

If the installation does not start automatically, use the Windows Explorer to find and double-click setup.exe<br />

on the CD.<br />

2. Provide your customer information, including the serial number supplied with your <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> installation.<br />

3. Choose your installation directory. If there are no previous versions of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on your<br />

system, the default directory is:<br />

C:\Program Files\Nuance\<strong>NaturallySpeaking</strong>9<br />

4. Choose your Setup Type (Preferred and higher editions)<br />

� Typical/Complete: Installs all options and speech files and requires the most disk space.<br />

� Custom: Lets you select which options and speech files to install. Customizing your installation options<br />

can greatly reduce the disk space required for installation.<br />

For the Professional edition, you can modify the following settings during a custom installation. These<br />

settings are applied to all users created with this installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, including<br />

users created from Windows XP limited accounts:<br />

� "Modify the application's settings for all users" displays the Options dialog box at the end of the<br />

installation. The Options dialog box lets you change <strong>Dragon</strong> <strong>NaturallySpeaking</strong>’s standard behavior,<br />

including specifying hot keys, customizing how text is formatted, initial microphone settings, and<br />

setting the how often your user files are backed up.<br />

� “Modify the administrative settings” displays the Administrative settings dialog box at the end of<br />

the installation. The Administrative settings dialog box lets you set up the Roaming User feature as<br />

well as well as set the backup location of your user files and restrict users from modifying<br />

commands and vocabularies.<br />

5. Enable the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> QuickStart option. (Optional)<br />

6. If you are upgrading from <strong>Version</strong> 7 or 8, you can select to upgrade your users as part of the <strong>Version</strong> 9<br />

installation by checking “Upgrade existing speech files to work with this installation.”<br />

7. Continue following the on-screen instructions. The setup program will install the files for <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> to your computer.<br />

Activating <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

The first time you start <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, you will be prompted to activate your copy of <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>. If you do not activate the software, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> will stop working after<br />

starting the product fives times.<br />

For more information on activation, please see the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> User's Guide.


Modifying settings for all users<br />

14<br />

For the Professional, you can modify the following settings during an installation:<br />

� "Modify the application's settings for all users" displays the Options dialog box at the end of the installation.<br />

The Options dialog box lets you change <strong>Dragon</strong> <strong>NaturallySpeaking</strong>’s standard behavior, including specifying<br />

hot keys, customizing how text is formatted, initial microphone settings, and setting the how often your user<br />

files are backed up.<br />

� “Modify the administrative settings” displays the Administrative settings dialog box at the end of the<br />

installation. The Administrative settings dialog box lets you set up the Roaming User feature as well as well as<br />

set the backup location of your user files and restrict users from modifying commands and vocabularies.<br />

These settings are applied to all users created with this installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, including<br />

users created from Windows XP limited accounts.<br />

Modifying settings for all users<br />

During an installation on a single computer, you can choose the Setup type :<br />

� Typical/Complete: Installs all options and speech files and requires the most disk space.<br />

� Custom: Lets you select which options and speech files to install.<br />

Choose custom to select the "Modify the application's settings for all users" and “Modify the administrative<br />

settings” options.<br />

MSI Installation Options<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> include a native Windows Installer (MSI) that lets you customize your installations as<br />

well as install across a network to multiple client machines. In addition, you use this service to modify, repair, or<br />

remove an existing <strong>NaturallySpeaking</strong> installations.<br />

This section describes:<br />

• Command line options specific to the Microsoft Installer Service (msiexec.exe).<br />

• Command line options specific to <strong>NaturallySpeaking</strong> setup using msiexec.exe<br />

• Command line options specific to how InstallShield Setup (setup.exe) calls msiexec.exe.<br />

• Command line samples<br />

MSI Installer location<br />

The compiled .MSI file is located on your installation CD. The files are named:<br />

• <strong>Dragon</strong> <strong>NaturallySpeaking</strong> (all editions): <strong>Dragon</strong> <strong>NaturallySpeaking</strong> 9.msi<br />

• SDK Client Edition (DSC): <strong>Dragon</strong> SDK Client Edition 9.msi


15<br />

• SDK Server Edition (DSS): <strong>Dragon</strong> SDK Server Edition 9.msi<br />

Installation notes:<br />

Unless otherwise noted<br />

• All command line options are case insensitive and may be combined<br />

• No options require special values based on the values of other options.<br />

In the examples below, user-supplied information is displayed between angle brackets. Do not use angle brackets<br />

() as part of the command line.<br />

Do not use quotation marks except when specifying a full path name with the -path command.<br />

Windows Installer (MSI) options<br />

The executable program that interprets packages and installs products is the Microsoft Installer Service<br />

(msiexec.exe) or MSI.<br />

All native MSI command line options are supported. All options are documented in the Microsoft MSI<br />

documentation, which can be found on:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/command_line_options.asp<br />

All Msiexec.exe command-line options must be prefaced with a forward slash (/) only.<br />

The following are the most useful MSI options for installing the <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

Option Description<br />

/q or /qn Quiet (or silent) mode installation.<br />

/L [i|w|e|a|r|u|c|m|o|p|v|x|+|!|*]<br />

Logfile<br />

Specifies the location of an installation logfile and specifies the<br />

nature of the information to be logged:<br />

i - Status messages.<br />

w - Nonfatal warnings.<br />

e - All error messages.<br />

a - Start up of actions.<br />

r - Action-specific records.<br />

u - User requests.<br />

c - Initial UI parameters.<br />

m - Out-of-memory or fatal exit information.<br />

o - Out-of-disk-space messages.


16<br />

p - Terminal properties.<br />

v - Verbose output.<br />

x - Extra debugging information. Only available on Windows Server<br />

2003.<br />

+ - Append to existing file.<br />

! - Flush each line to the log.<br />

"*" - Wildcard, log all information except for the v and x options. To<br />

include the v and x options, specify "/L*vx".<br />

PROPERTY=VALUE Overrides default public property value. For example, setting<br />

"XYZ=ABC" will replace the default property value of XYZ to ABC.<br />

MSI options specific to <strong>NaturallySpeaking</strong><br />

This section described the msiexec.exe options specific to <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

The <strong>NaturallySpeaking</strong> command line options do not need to be prefaced hyphens or slashs.<br />

Note: Launching automatically sets the property<br />

"XYZ" to the value of "ABC" internally and continues the installation. However, installation through setup.exe will<br />

still require the "/v" command line option in order to pass the property override value on to the MSI service.<br />

The following table documents the supported global property overrides. Unless noted otherwise, all property<br />

values are in UPPERCASE.<br />

ADDLOCAL=Feature1,Feature2,...<br />

or<br />

ADDLOCAL=ALL<br />

Option Description<br />

The value of the ADDLOCAL property is a list of features that<br />

are delimited by commas, and are to be installed locally.<br />

To install all features locally (including the speech files), use<br />

ADDLOCAL=ALL on the command line.<br />

ADVERTISE=Feature1,Feature1,... The value of the ADVERTISE property is a list of features<br />

delimited by commas that are to be advertised.<br />

To install all features as advertised, use ADVERTISE=ALL on<br />

the command line.<br />

The ADVERTISE option overrides the ADDLOCAL option.<br />

The best method for specifying a custom installation is to set<br />

the ADDLOCAL property to ALL and then specify the<br />

ADVERTISE property to match those features you don't want<br />

installed locally. A list of the features that may be set for<br />

installation is listed below.<br />

DEFAULTSINI="c:\xyz.ini" Specifies a "default settings" file, which will allow an installer<br />

to change the default behavior of the product for all users.


17<br />

The specified file contains settings that will be merged into<br />

the nsdefaults.ini file at installation time. Note that this file<br />

must be in an ".ini" file format. In other words, any settings<br />

you want to merge must also have the section notated as well<br />

as the value and data. If only values and data are set in this<br />

file (without the section name encased in brackets), the<br />

settings will not be merged.<br />

For a default installation, the nsdefaults.ini is located in:<br />

C:\Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>NaturallySpeaking</strong>9<br />

SERIALNUMBER=abcde-fgh-ijkl-mnop-qr The serial number, in the form of "abcde-fgh-ijkl-mnop-qr".<br />

A serial number is required for all installations. If one is not<br />

already built into the ereg.ini file, then a valid one must be<br />

specified on the command line.<br />

Note: Specifying a serial number on the command line does<br />

not bypass the serial number checking within setup.<br />

INSTALLDIR="c:\xyz" The default installation directory.<br />

Long path names need to have their quote strings "escaped"<br />

(\"). If you do not use this option, DSC is installed to the<br />

defualt directory: [PROGRAMFILES]\Nuance\<strong>Dragon</strong> SDK<br />

Client Edition<br />

If you are upgrading from a previous version, you must set<br />

INSTALLDIR to that versions installation directory.<br />

PRODUCTUPDATEFLAG=0 (or 1 or -1) Sets the default state of the checkbox at the end of<br />

installation to determine if installation will automatically<br />

check the web for product updates.<br />

A value of 0 (zero) will turn the checkbox off by default. A<br />

value of 1 (one) will turn it on by default.<br />

To disable the option entirely (turn the option off and<br />

suppress the display of the checkbox<br />

altogether), set the value to -1.<br />

The default setting is "1" (enable the checkbox and check for<br />

product updates by default).<br />

NOTYPICAL=1 Sets the default choice on the SetupType dialog to "Custom",<br />

rather than "Typical/Complete".<br />

RebootYesNo=No Stops Windows from rebooting, even if the installation will not<br />

be complete until Windows is restarted.<br />

This option will also suppress the prevention of installation<br />

when a reboot is necessary.<br />

Note case: This should not be uppercased.<br />

NOMINIMUM=1 Will override the enforcement of minimum memory/speed<br />

requirements for installation.


QUICKSTART=0 (or 1) Set the default state of "Enable QuickStart Mode" checkbox to<br />

enable QuickStart and to create shortcut for "<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>"<br />

in the Windows Startup folder.<br />

18<br />

A value of 0/1 will turn checkbox off/on accordingly.<br />

REINSTALL=Feature1,Feature2,... (or ALL) The value of the REINSTALL property is a list of features<br />

delimited by commas that are to be reinstalled. To reinstall all<br />

features use REINSTALL=ALL on the command line.<br />

REINSTALLMODE={specifying the type of<br />

reinstallation to perform}<br />

If the REINSTALL property is set, the REINSTALLMODE<br />

property should also be set, to indicate the type of reinstall to<br />

be performed. If the REINSTALLMODE property is not set,<br />

then by default all files that are currently installed are<br />

reinstalled, IF the currently installed file is a lesser version (or<br />

is not present). By default, no registry entries are rewritten.<br />

Note that even if REINSTALL is set to ALL, only those features<br />

that were already installed previously are reinstalled. Thus, if<br />

REINSTALL is set for a product that is yet to be installed, no<br />

installation action will take place at all.<br />

For more information, see:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/<br />

en-us/msi/setup/reinstall.asp<br />

The REINSTALLMODE property is a string that contains letters<br />

specifying the type of reinstall to perform. Options are<br />

case-insensitive and order-independent. This property should<br />

normally always be used in conjunction with the REINSTALL<br />

property. However, this property can also be used during<br />

installation, not just reinstall.<br />

If the REINSTALLMODE property is defined without also<br />

defining the REINSTALL property, then the specified<br />

"detection" modes still apply and specify the "overwrite"<br />

mode for a normal installation. The REINSTALLMODE<br />

property only affects those features that are selected<br />

normally for installation. The presence of the<br />

REINSTALLMODE property does not reinstall features. The<br />

reinstallation of features requires the presence of the<br />

REINSTALL property.<br />

For example, to launch a minor upgrade without using<br />

setup.exe, you must set the following properties through the<br />

command line:<br />

REINSTALL=ALL<br />

REINSTALLMODE=vemus<br />

Therefore, to install a minor upgrade through the .msi file,<br />

you'll need to issue the following command line:<br />

msiexec /i "


19<br />

For more information on REINSTALLMODE and the reinstall<br />

option codes, see:<br />

http://msdn.microsoft.com/library/default.asp?url=/library/<br />

en-us/msi/setup/reinstallmode.asp<br />

ROAMINGUSERINI="c:\xyz.ini Specifies a "roaming user ini file", which contains settings to<br />

be merged into nssystem.ini at installation time. These are<br />

the same settings as displayed in the Roaming User section of<br />

the Administrative Settings dialog box.<br />

Long path names need to have their quote strings "escaped"<br />

(\").<br />

The default is empty (no .ini file will be used).<br />

For more information on the roaming user ini file<br />

ROAMINGUSEROPTIONS="c:\xyz.ini" Specifies a "roaming user options file", which contains<br />

settings to be merged into nssystem.ini at installation time.<br />

Long path names need to have their quote strings "escaped"<br />

(\").<br />

The default is empty (no .ini file to be merged).<br />

Note that this file must be in an ".ini" file format. In other<br />

words, any settings you want to merge must also have the<br />

section notated as well as the value and data. If only values<br />

and data are set in this file (without the section name encased<br />

in brackets), the settings will not be merged.<br />

SETDEFAULTS=0 (or 1) Sets the default state of "Modify the application's settings for<br />

all users" checkbox to display the Options dialog box at the<br />

end of the installation. The Options dialog box lets you change<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong>’s standard behavior, including<br />

specifying hot keys, customizing how text is formatted, initial<br />

microphone settings, and setting the how often your user files<br />

are backed up.<br />

A value of 0/1 will turn checkbox off/on accordingly.<br />

SETADMINS=0 (or 1) Set the default state of "Modify the administrative settings"<br />

checkbox to display the Administrative settings dialog box at<br />

the end of the installation. The Administrative settings dialog<br />

box lets you set up the Roaming User feature as well as well<br />

as set the backup location of your user files and restrict users<br />

from modifying commands and vocabularies.<br />

A value of 0/1 will turn checkbox off/on accordingly.<br />

WEBREGISTRATION=1 (or 0) Determines whether or not to launch the on-line product<br />

registration form.<br />

0 disables the product registration.<br />

The default is 1 (enabled).<br />

Feature variables that may set on the command line through the ADDLOCAL or ADVERTISE<br />

property


Note the following when specifying features on the command line:<br />

20<br />

• If a feature doesn't exist in a particular edition or language, overriding it's default property has no effect.<br />

• Some features (For example, the Speech feature) have subfeatures. Setting these features on the<br />

command line will automatically turn on the properties of all subfeatures, unless those subfeatures have an<br />

additional override also specified.<br />

Subfeatures are indented from their parent features, and any information in parentheses is not included in<br />

the feature name.<br />

The following features can be specified from the command line:<br />

Feature Sub-feature Sub-feature Sub-feature<br />

NatSpeak<br />

Note: Must be<br />

included in<br />

ADDLOCAL,<br />

otherwise<br />

installation will<br />

fail<br />

Samples (Sample<br />

Commands files)<br />

TTS<br />

(Text-to-Speech)<br />

TTSDEU (German<br />

Text-to-Speech)<br />

TTSENX (English<br />

Text-to-Speech)<br />

TTSESP (Spanish<br />

Text-to-Speech)<br />

TTSFRA (French<br />

Text-to-Speech)<br />

TTSITA (Italian<br />

Text-to-Speech)<br />

TTSNLD (Dutch<br />

Text-to-Speech)<br />

Tutorial TutDEU (German<br />

Tutorial)<br />

TutENX (English<br />

Tutorial)<br />

TutESP (Spanish<br />

Tutorial)<br />

TutFRA (French<br />

Tutorial)<br />

TutITA (Italian Tutorial)<br />

TutNLD (Dutch Tutorial)<br />

Speech DEU (German) DEUGeneral (German<br />

General)<br />

DEULegal (German<br />

Legal)<br />

ENX (English) AUS (Australian<br />

English)<br />

Sub-features for ENU (US English):


21<br />

ITA (Italian)<br />

NLD (Dutch)<br />

FRA (French)<br />

The Roaming User .ini file<br />

ENG (UK English)<br />

IND (Indian English)<br />

SEA (SouthEast Asian<br />

English)<br />

ENU (US English)<br />

ESP (Spanish) ESC (Castilian<br />

Pronunciations)<br />

ESL (Latin American<br />

Pronunciations)<br />

General (US English General)<br />

Teens (US English Teens)<br />

Legal (US English Legal)<br />

Cardiology (US English Medical<br />

Cardiology)<br />

Emergency (US English Medical<br />

Emergency)<br />

Gastroenterology (US English Medical<br />

Gastroenterology)<br />

GeneralPractice (US English Medical<br />

GeneralPractice)<br />

Medical (US English Medical No Specialty)<br />

MentalHealth (US English Medical<br />

MentalHealth)<br />

Neurology (US English Medical<br />

Neurology)<br />

ObGyn (US English Medical ObGyn)<br />

Oncology (US English Medical Oncology)<br />

Orthopaedic (US English Medical<br />

Orthopaedic)<br />

Pathology (US English Medical Pathology)<br />

Pediatrics (US English Medical Pediatrics)<br />

Radiology (US English Medical Radiology)<br />

Surgery (US English Medical Surgery)<br />

You can create a "roaming user ini file" to change the roaming user settings at installation time. These options are<br />

the same settings that can be set as set with displayed in the RoamingUserOption<br />

DgnEngineControl::RoamingUserOption using the DgnRoamingUserOptionConstants. For more information on the<br />

DgnRoamingUserOptionConstants, see the API Reference Help file.<br />

Option Description<br />

Roaming User On=0 (or 1)<br />

Roaming User Master<br />

Directory="existing<br />

directory"<br />

Roaming User Local Cache<br />

Directory="existing<br />

directory"<br />

Turns on the Roaming User feature.<br />

Default 0 = Off<br />

The location of the master roaming user you want to open.<br />

This directory must exist.<br />

The location of the local copy of the roaming user.<br />

The default location is: Documents and Settings\All Users\Application


Roaming User Restrict<br />

Local User Access=1 (or 0)<br />

Roaming User Copy<br />

<strong>Dragon</strong> Log=0 (or 1)<br />

Roaming User Limited<br />

Network Traffic=0 (or 1)<br />

Roaming User Always<br />

Break Lock=0 (or 1)<br />

Roaming User Max<br />

Container Size=500MB<br />

ASW Override=0 (or 1)<br />

Roaming User Do Not Copy<br />

Dra Files=0 (or 1)<br />

Example .ini file:<br />

[Settings]<br />

Roaming User On=1<br />

22<br />

Data\Nuance\<strong>Dragon</strong> SDK Client Edition\Roaming User\.<br />

Permits non-roaming user to be opened when the roaming user feature is active.<br />

Defaults to "1" which restricts access to roaming user only and prevents dictating<br />

with a non-roaming (local) user by accident.<br />

Copies the <strong>Dragon</strong>.log file from the local roaming user location to the master<br />

roaming user location at the same time that the program synchronizes the local and<br />

the master roaming user.<br />

Default 0= Off<br />

Transfers local user changes to the Options dialog box to the master roaming user<br />

when the program synchronizes the local and the master roaming user.<br />

Default 0= Off<br />

Ask before breaking the locks on network users (recommended).<br />

A network lock prevents the opening of a roaming user while that user is already<br />

open. While this process does not take a long time, network problems can cause a<br />

lock to become "stuck" and not release when the open process is completed. When<br />

this happens, the next time anyone tries to open that user, they will see a message<br />

informing them of the lock and give them the option of overriding it.<br />

Default 0 = ask before breaking lock<br />

Controls the maximum size for each container directory in the master user directory.<br />

Defaults to 500 MB, max of 10000 MB<br />

Runs a Volume Check and the Microphone Quality Check each time you open a<br />

roaming user.<br />

Turn this option on if your users experience reduced accuracy because of differences<br />

in the microphone, sound card, and ambient sound levels of each roaming user<br />

location.<br />

Default 0 = off<br />

Roaming User Master Directory=G:\TEMP\user1<br />

Roaming User Restrict Local User Access=0<br />

Prevents making the files that contain the acoustic data from the latest dictation<br />

session available to the Acoustic Optimizer when the program synchronizes the local<br />

and the master roaming user.<br />

This prevents the Acoustic Optimizer from running on a local roaming user. If you do<br />

not wish to retain this information, you can use this option to prevent the transfer.


Roaming User Copy <strong>Dragon</strong> Log=1<br />

Roaming User Limited Network Traffic=1<br />

Roaming User Local Cache Directory=D:\roam<br />

InstallShield (setup.exe) options<br />

Like the Microsoft Installer Service (msiexec.exe), the InstallShield Setup program (setup.exe) can accept a<br />

number of command line options and can pass options through setup.exe to the included .msi file.<br />

All setup.exe command-line options must be prefaced with a forward slash (/) only.<br />

All options are documented in the InstallShield documentation:<br />

http://helpnet.installshield.com/robo/projects/helplibdevstudio9/IHelpSetup_EXECmdLine.htm<br />

The following are the most useful command line options for installing DSC:<br />

/v<br />

/s<br />

23<br />

Option Description<br />

/L (followed by the<br />

Windows Language<br />

Code)<br />

Passes command line and public properties options to the Windows Installer<br />

(msiexec.exe) installation.<br />

If you run setup.exe (rather than msiexec.exe) to install DSC, you can specify any<br />

Windows Installer command line options using the "/v" option.<br />

For example, for MSI quiet mode, you'll need to run setup.exe /v/qn. To set the public<br />

property of XYZ to "ABC", you would run setup.exe /v"XYZ=ABC".<br />

Formerly "noui"<br />

Runs setup in a "silent" mode, suppressing the initialization window. However, unless<br />

the MSI installation is also specified as silent, the MSI installation will run normally.<br />

In order to run both setup.exe and msiexec.exe silently, you will need to combine the /s<br />

and the /v options. Use the following command line: setup.exe /s /v/qn.<br />

Using these options, no dialogs of any kind will be displayed during installation or<br />

uninstallation. All messages are suppressed or, if a log file is also specified, sent to the<br />

MSI log file in the user-specified temp directory.<br />

The "noui" command line flag is no longer supported.<br />

For Multi-lingual installations, specifies the language to use for installation and bypassed<br />

the "Choose Installation Language" dialog box.<br />

For example to launch the installation in French, the command line would be setup.exe<br />

/l1036.<br />

Extracting msi files from single-file installation executables (setup.exe files)<br />

The following options are designed to extract .msi/.mst files from Windows Installer-oriented setup.exe<br />

distribuitions. These options will not install any files; they will only extract an installable set of files into a specified


directory.<br />

/a<br />

/v<br />

24<br />

Option Description<br />

/l<br />

(followed by the Windows<br />

Language Code)<br />

EXTRACTFILES="c:\xyz"<br />

Sample Command line<br />

Administrative installation option. This instructs setup.exe to perform an<br />

administrative installation instead of a normal installation. This option is required<br />

when trying to extract the .msi files.<br />

Passed arguments to Windows Installer. See above for details. This option is<br />

required when trying to extract the .msi files.<br />

Specifies the language to use for installing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> . For<br />

example, to launch the installation in French, the command line would be<br />

. The following language codes are supported for installing<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

1031=German<br />

1033=English<br />

1034=Spanish<br />

1036=French<br />

1040=Italian<br />

1043=Dutch<br />

This option creates an MST file for the language that is specified, for example,<br />

1036.MST.<br />

The directory to which the .msi/.mst files will be extracted. Long path names need<br />

to have their quote strings "escaped" (\"). The property must be set when trying to<br />

extract the .msi files. If the specified directory doesn't exist, it will be created.<br />

Therefore, a sample extraction of msi files from a single file executable might look<br />

like this: setup.exe /a /s /v"EXTRACTFILES=c:\temp\msifiles"<br />

The following example silently installs <strong>NaturallySpeaking</strong> locally with a specified set of vocabularies:<br />

setup /s /v /qn INSTALLDIR=\"c:\\ns8\" SERIALNUMBER=abcde-fgh-ijkl-mnop-qr ADDLOCAL=ALL<br />

ADVERTISE=Cardiology,Emergency,Gastroenterology,GeneralPractice,MentalHealth,Neurolog<br />

y,ObGyn,Oncology,Orthopaedic,Pathology,Pediatrics,General,Teens /Liwmo!e c:\\Setup.log<br />

The table below describes each option:<br />

/s<br />

Option description<br />

Runs setup in a "silent" mode, suppressing the<br />

initialization window.


v<br />

25<br />

Passes command line and public properties options to the<br />

Windows Installer (msiexec.exe) installation.<br />

In order to run both setup.exe and msiexec.exe silently,<br />

you will need to combine the /s and the /v options. Use the<br />

following command line: setup.exe /s /v/qn.<br />

Using these options, no dialogs of any kind will be<br />

displayed during installation or uninstallation. All<br />

messages are suppressed or, if a log file is also specified,<br />

sent to the MSI log file in the user-specified temp<br />

directory.<br />

/qn Quiet (or silent) mode installation.<br />

INSTALLDIR=\"c:\\ns8\" Sets the installation directory to C:\ns8<br />

SERIALNUMBER=abcde-fgh-hij-klmo-pq<br />

The serial number. A serial number is required for all<br />

installations.<br />

ADDLOCAL=ALL ADDLOCAL=ALL installs all features locally.<br />

ADVERTISE=Cardiology,Emergency,Gastroentero<br />

logy,<br />

GeneralPractice,MentalHealth,Neurology,ObGyn,<br />

Oncology,Orthopaedic,Pathology,Pediatrics,Gene<br />

ral,Teens<br />

/Liwmo!e c:\\Setup.log<br />

Installs the specified vocabularies.<br />

The best method for specifying a custom installation is to<br />

set the ADDLOCAL=ALL and then specify the ADVERTISE<br />

property to match those features you don't want installed<br />

locally.<br />

/L specifies the location of an installation logfile and<br />

specifies the nature of the information to be logged:<br />

i - Status messages.<br />

w - Nonfatal warnings.<br />

m - Out-of-memory or fatal exit information.<br />

o - Out-of-disk-space messages.<br />

! - Flush each line to the log.<br />

e - All error messages.<br />

c:\\Setup.log - writes out the log file to c:\setup.log<br />

Using the User Upgrade Wizard to upgrade multiple users<br />

Migrate your existing user files and vocabularies to <strong>Version</strong> 9.<br />

If you choose not to upgrade your user files and vocabularies during the upgrade, you can do so at a later time<br />

by running the <strong>Version</strong> 9 Upgrade Tool.<br />

Use the Select Users to Upgrade screen to create a list of users that you want to upgrade. The wizard starts by<br />

including all the users in the current folder as candidates to upgrade. You add users to the list by clicking the<br />

Add button and browsing for additional users in other locations. You remove users from the list by selecting<br />

them and clicking the Remove button. Once you have adjusted the list of user files to only the ones you want<br />

to upgrade, click Next.<br />

Edition considerations


26<br />

You must upgrade to the same edition or higher and to the same language.<br />

For example, if you started with <strong>Version</strong> 8 German/English and you upgrade to <strong>Version</strong> 9 English only, your<br />

<strong>Version</strong> 8 German users will not be upgraded. Upgrading to <strong>Version</strong> 9 German/English will upgrade both your<br />

German and English users. After upgrading, you can install other <strong>Version</strong> 9 languages.<br />

User files to upgrade<br />

Lists the location and name of all the users that the wizard will upgrade.<br />

Note: The current location of the user files is called "Old Location" in this screen.<br />

Number of users to upgrade<br />

Displays the total number of users the wizard will upgrade.<br />

Add<br />

Opens a Browse for Folder window in which you can locate additional users for the wizard to upgrade.<br />

Remove<br />

Deletes a selected user from the User Upgrade wizard.<br />

User Upgrade Wizard: Choose Users to Upgrade<br />

The User Upgrade Wizard guides you through the process of upgrading user files created in <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> version 6 and version 7. The wizard cannot upgrade user files created by versions of <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> prior to version 6. Use the Choose Users to Upgrade screen to select the user or users that<br />

you want to upgrade from among the following choices:<br />

User only<br />

Select this option to upgrade the user you selected on the Open User dialog box.<br />

All user files in the same location as (recommended)<br />

Select this option to upgrade all the users that the wizard finds in the location of the selected user at the same<br />

time.<br />

Custom: choose which users to upgrade:<br />

Opens the Select Users to Upgrade screen where you can further refine the list of users to upgrade.<br />

Once you have made a selection, click Next.<br />

User Upgrade Wizard: Choose Destination


At the same time that the User Upgrade Wizard modifies your user files to work with <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

version 8, it can move a copy of the upgraded user to another location while keeping the old files untouched.<br />

This allows you to return to the old user files in case you need them again, and it makes the files compatible<br />

with operating systems, like Windows XP, that store all user data in the Documents and Settings folder.<br />

Destination for upgraded user files<br />

Click the Browse button or select a new destination from the list if you want to choose a destination other than<br />

the suggested destination.<br />

Advanced<br />

Click the Advanced button to open the Advanced Options screen where you can alter the way that the wizard<br />

upgrades the user.<br />

User Upgrade Wizard: Advanced Options<br />

The Advanced Options screen allows you to make a finer adjustment to how the wizard upgrades the user than<br />

you are normally can make on the Choose Destination screen. The Advanced Options screen contains the<br />

following information and allows you to make the following changes:<br />

User to upgrade<br />

27<br />

This box contains the following information about each user at the current location:<br />

Old Location<br />

User<br />

Location of the current (not yet upgraded) user files.<br />

The name of the user.<br />

Vocabulary<br />

The original vocabulary from which the user was created.<br />

New Base Vocabulary<br />

The new new vocabulary that the User Upgrade Wizard will use for the upgraded user if the old vocbulary is<br />

no longer supported by <strong>Dragon</strong> <strong>NaturallySpeaking</strong>. If the current vocabulary is supported, the message<br />

appears.<br />

New Location<br />

The location that the wizard recommended or that you chose on the Choose destination screen.<br />

New Base Vocabulary


28<br />

If a different base vocabulary is available for upgrading the user, you can use this list to select it.<br />

New Location<br />

If you want to choose a new location for the user, you can use this list to select it.<br />

Upgrading Users with Custom Vocabularies<br />

If you have custom vocabularies, upgrading your V8 users will maintain the customized vocabularies associated<br />

with those users but will modify the vocabulary name. If you want to further modify and re-distribute that<br />

customized vocabulary to your V9 users, use the procedure outlined below.<br />

When you upgrade a user based on the custom vocabulary, all your customizations will be maintained but the<br />

vocabulary's base type will be changed. For example, V8 users who used US English | Large | Nuance vocabulary<br />

with a topic ID of 9005 will be upgraded to use the General - Large vocabulary; that upgraded user's vocabulary<br />

will contain all customizations in the original V8 vocabulary.<br />

Once the user is upgraded, you can continue to modify the vocabulary using the Voctool.<br />

Step 1: Export any custom words added to the custom vocabulary<br />

If you added any additional custom words to the custom vocabulary, you must first export those words. To export<br />

custom words:<br />

1. Click Words>Export... from the <strong>Dragon</strong>Bar. This displays the The Export Custom Words dialog box.<br />

2. Enter the path and name of the file containing the custom words in your vocabulary that you want to create,<br />

or use the Save in list to find a location for the file you want to create.<br />

Step 2: Upgrade a user with a customized vocabulary<br />

To upgrade V8 users with a customized vocabulary:<br />

1. Run the User Upgrade Wizard. To run the wizard, select <strong>Dragon</strong> <strong>NaturallySpeaking</strong> 9.0><strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> Tools>Upgrade Users.<br />

2. In the User Upgrade Wizard, select a V8 user that uses a customized vocabulary.<br />

3. Click Next and follow the on-screen prompts.<br />

The User Upgrade Wizard will display the original vocabulary from which the user was created and let you choose<br />

a V9 base vocabulary that the User Upgrade Wizard will use for the upgraded user.<br />

Step 3: Import custom words to the upgraded user<br />

If you exported words in Step 1, you know must import those words. To import a word list:<br />

1. Click Words>Import... from the <strong>Dragon</strong>Bar. This displays the The Add Words from Word Lists wizard.<br />

2. Click Next to add the file you created in Step 1.


Step 4: Export the customized vocabulary<br />

You can share vocabularies among different users by first exporting a vocabulary from one user and then importing<br />

it to a new user. Use the following procedure to export a vocabulary. To export a vocabulary:<br />

Notes<br />

29<br />

1. Create a folder in which to save the exported vocabulary files.<br />

2. Open the upgraded V8 user that uses the customized vocabulary.<br />

3. On the <strong>NaturallySpeaking</strong> menu of the <strong>Dragon</strong>Bar, click or say "Manage Vocabularies."<br />

4. On the Manage Vocabularies dialog box, select the vocabulary you want to export and then export it.<br />

5. Locate and open the target folder, enter a name for the exported vocabulary in the File Name box, and then<br />

save it.<br />

6. Click or say "Close" on the Manage Vocabularies dialog box to save and close it.<br />

• Exporting a vocabulary creates a copy of the four files that make up the vocabulary in the new location.<br />

These files can be accessed by the Data Distribution Tool and nsadmin to create new custom base<br />

vocabularies.<br />

Step 5: Use nsadmin or the Data Distribution tool to copy the exported vocabulary<br />

Using the nsadmin command line or the Data Distribution Tool, you can import the vocabulary your created in Step<br />

2 as a base vocabulary on any <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation.<br />

By adding a base vocabulary to a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation, you can then<br />

You can then use the new vocabulary to create new users or add a new a new vocabulary to the an existing user.<br />

When you run nsadmin or the Data Distribution Tool to import the the exported vocabulary to your <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> installation, make sure to give the new vocabulary the same name and topic ID as the V8<br />

customized vocabulary.<br />

For example, if your V8 customized vocabulary was named US English | Large | Nuance topic ID 9005, you would<br />

use nsadmin or the Data Distribution Tool to create a new base vocabulary named US English | Large | Nuance with<br />

a topic ID of 9005.<br />

<strong>Version</strong> 9 File Structure<br />

Upgrading from <strong>Dragon</strong> <strong>NaturallySpeaking</strong> V7 or V8 to V9 will automatically relocate some <strong>NaturallySpeaking</strong><br />

directories and files.<br />

Note: The following directory structures and file locations assume an installation to a default location.<br />

V7.0 Directory structure for all supported Windows operating systems<br />

The V7.0 directory structure before upgrading to V9:


C:\Program Files\ScanSoft\<strong>NaturallySpeaking</strong><br />

\Custom<br />

\Data<br />

\Help<br />

\Program<br />

\Results<br />

\Training<br />

\Tutorial (optional installation)<br />

\Users<br />

Note: The \Custom directory is present only if you use nsadmin to create custom words, commands, or<br />

vocabularies. The <strong>Dragon</strong> <strong>NaturallySpeaking</strong> V7.3 directory structure is the same as V8.<br />

V8 Windows 2000/XP Pro/XP Home directory structure<br />

30<br />

The V8 directory structure before upgrading to V9:<br />

C:\Program Files\ScanSoft\<strong>NaturallySpeaking</strong><br />

\Help<br />

\Program<br />

\Tutorial (optional)<br />

C:\Documents and Settings\All Users\Application Data\ScanSoft\<strong>NaturallySpeaking</strong>\<br />

\Custom<br />

\Data<br />

\Data\Training<br />

\Users<br />

C:\Documents and Settings\\Application Data\ScanSoft\<strong>NaturallySpeaking</strong>\<br />

\Results<br />

9 Windows 2000/XP Pro/XP Home/Windows Server 2003 directory structure<br />

The Directory structure after installing V9 on Windows 2000/XP Pro/XP Home/Windows 2000 Advanced<br />

Server/Windows Server 2003:<br />

C:\Program Files\Nuance\<strong>NaturallySpeaking</strong>9<br />

\Help<br />

\Program<br />

\Tutorial (optional)<br />

C:\Documents and Settings\All Users\Application Data\Nuance\<strong>NaturallySpeaking</strong>9\<br />

\Custom<br />

\Data<br />

\Data\Training<br />

\Users<br />

C:\Documents and Settings\\Application Data\Nuance\<strong>NaturallySpeaking</strong>9\<br />

\Results<br />

Cleaning up after uninstalling <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

The following files will remain on your machine after you uninstall <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:


31<br />

� C:\Windows\Speech<br />

� VText.dll<br />

� Vdict.dll<br />

� WrapSAPI.dll<br />

� XTel.Dll<br />

� Xcommand.dll<br />

� Xlisten.dll<br />

� Xvoice.dll<br />

� spchtel.dll<br />

� speech.cnt<br />

� speech.dll<br />

� vcauto.tlb<br />

� vcmd.exe<br />

� vcmshl.dll<br />

� vtxtauto.tlb<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> installed these files for Microsoft SAPI4 support. If you do not have other speech<br />

applications that require SAPI4, you can safely remove these files manually. If have installed other speech<br />

applications that require SAPI4 support, you may need to re-install those applications if you remove the files.<br />

Command line interface<br />

You can use command line options to modify the way in which <strong>Dragon</strong> <strong>NaturallySpeaking</strong> starts up. These<br />

switches are used in the following syntax:<br />

natspeak /switch<br />

Where /switch is the switch from the following table:<br />

Switch Function<br />

/diagnose Runs <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in diagnostic mode. Outputs<br />

information into the <strong>Dragon</strong>.log file and exits.<br />

/user Automatically loads the user specified by <br />

/topic Automatically loads the topic specified by (Professional edition<br />

only)<br />

/quick Runs <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in quick mode. QuickStart mode starts<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> without loading a user or any speech models<br />

when you start your computer. Only the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> tray<br />

icon is visible. When you click on the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> desktop<br />

icon, the Open User dialog box immediately appears. When you exit


32<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> the program returns to the QuickStart mode<br />

and remains in memory with a reduced footprint (approximately 10 MB).<br />

/SetDefaultOptions Displays the Options dialog box at the end of the installation. The<br />

Options dialog box lets you change <strong>Dragon</strong> <strong>NaturallySpeaking</strong>’s<br />

standard behavior, including specifying hot keys, customizing how text<br />

is formatted, initial microphone settings, and setting the how often your<br />

user files are backed up.<br />

/SetDefaultAdministrativeOptions Displays the Administrative settings dialog box at the end of the<br />

installation. The Administrative settings dialog box lets you set up the<br />

Roaming User feature as well as well as set the backup location of your<br />

user files and restrict users from modifying commands and vocabularies.<br />

Setting up Roaming Users<br />

About the Roaming User feature<br />

The Roaming User feature lets users dictate with <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from different network locations<br />

using a variety of computing devices without having to create and train individual user files at each location.<br />

Some situations that the Roaming User feature makes possible:<br />

� A doctor may need to dictate reports in a medical office building using a desktop computer, in a hospital<br />

room using a Tablet PC, or at home using a laptop computer. The Roaming User feature allows the doctor<br />

to use the same set of user files containing the same vocabulary words with the acoustic information from<br />

each location.<br />

� You have a user who uses the same laptop at multiple offices and at home. Before leaving the office, your<br />

user loads a user from a central location on the network to his laptop. Once home, the user dictates and<br />

corrects as they normally would. When they return to the office, the user reconnects the laptop to the<br />

network and the Roaming User feature synchronizes the updated user files on the laptop with those at the<br />

network’s central location the next time you load that user.<br />

Master Roaming User and Local Roaming User<br />

With the Roaming User feature, each <strong>Dragon</strong> <strong>NaturallySpeaking</strong> user has a single Master Roaming User that<br />

can be opened from multiple networked machines running <strong>Dragon</strong> <strong>NaturallySpeaking</strong>. The Master Roaming<br />

User is stored on a network location accessible to your users.<br />

When a Master Roaming User is opened from that central network location, <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

transfers a copy of that user to the local machine. That local copy is called the Local Roaming User.<br />

The Local Roaming User is a copy of the user data taken from the Master Roaming User but modified locally by<br />

corrections and acoustic data gathered during a dictation session.<br />

For example, you can set a central storage device to contain all your Master Roaming User files. By loading a<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> user from the central network location, your users can dictate at any computer<br />

where <strong>Dragon</strong> <strong>NaturallySpeaking</strong> is installed. When users exit <strong>Dragon</strong> <strong>NaturallySpeaking</strong> and save the changes<br />

to their user files, these changes are saved in that central location. The next time the user runs <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>, all the changes they saved are available regardless of which computer on the network they


33<br />

use for dictation.<br />

For more information<br />

For more information, see:<br />

� Setting up the Roaming User Feature<br />

� Creating and opening a Roaming User<br />

� Using multiple dictation sources with a single user<br />

� Synchronizing Master and Local Roaming Users<br />

� Running the Acoustic and Language Model Optimizer for roaming users<br />

Setting up the Roaming User feature<br />

You must set up the Roaming User feature on each computer where you want users to dictate with a Roaming<br />

User.<br />

Step 1: Set up and create a network storage location for the Master Roaming<br />

User files<br />

Before setting up the Roaming User feature on individual machines, you must set up the network location for<br />

the Master Roaming Users. The location you pick must be accessible to all computers where users will dictate<br />

using a Roaming User. You can create multiple network storage locations.<br />

The Roaming User feature supports the following types of locations:<br />

� Mapped Drives - used to connect to a shared network folder that has a drive letter assigned to it.<br />

� UNC Paths - used to connect to a shared network folder using the Universal Naming Convention (UNC) to<br />

locate a user. The format is: \\servername\sharename\path\filename.<br />

� HTTP (http:) - used to connect to machine on the internet or your local intranet. The format is:<br />

http://myserver.com/webdav<br />

Make sure your server has Web-based Distributed Authoring and <strong>Version</strong>ing (WebDAV) turned on.<br />

Note: Additional installation of a third-party web server application called WebDAV is required. WebDAV software<br />

is required in order to access and secure DNS user profiles on the Internet location. The WebDAV application is<br />

available free of charge at www.webdav.org.<br />

Step 2: Close any open users.<br />

Before you can enable the Roaming User feature, you must first close any open users:<br />

� If the Open User dialog box appears when you start <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, click Cancel.<br />

� If a user opens automatically (<strong>Dragon</strong> <strong>NaturallySpeaking</strong> will do this if there is only one user available), click<br />

Close User on the <strong>Dragon</strong>Bar <strong>NaturallySpeaking</strong> menu.<br />

Step 3: Turn on the Roaming User feature


34<br />

After closing any open users:<br />

1. Click Administrative Settings on the <strong>Dragon</strong>Bar Tools menu. This displays the Administrative Settings<br />

dialog box.<br />

2. On the Roaming tab, select Enable.<br />

Step 4: Specify the location of the Master Roaming User<br />

On each computer where you plan to have users dictating as a Roaming Users, you must tell that installation<br />

of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> where the Master Roaming user is located, and if necessary, create that location.<br />

After selecting Enable on the Roaming tab:<br />

1. Click the Add button. This displays the Roaming User Network Location dialog box. You use the Roaming User<br />

Network Location dialog box to define the network location of the master roaming users. The location you<br />

pick must be accessible to all computers on the network that you want available for dictation with <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>.<br />

2. Set the Display Name and the Network Location. The Roaming User feature supports the following types of<br />

locations:<br />

� Mapped Drive - the format is: \. For example, y:\roaming.<br />

� UNC Path - the format is: \\servername\sharename\path\filename.<br />

� HTTP (http:) - the format is: http://myserver.com/webdav.<br />

3. For HTTP locations, click the HTTP Settings button to set information specific to your HTTP connection like<br />

Authentication, Firewall, and Proxy Server information.<br />

After specifying the HTTP Settings, use the Test Connection button to make sure your settings are correct.<br />

Note: Additional installation of a third-party web server application called WebDAV is required. WebDAV software<br />

is required in order to access and secure DNS user profiles on the Internet location. The WebDAV application is<br />

available free of charge at www.webdav.org.<br />

For more information on setting the location of the master roaming user, see Roaming User Network Location.<br />

Step 5: Specify the location of a Local Roaming User<br />

When a user opens a Master Roaming User, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> transfers a copy of that user to the local<br />

machine. That local copy is called the Local Roaming User.<br />

You can set this location, called , from the the Administrative Settings dialog box.<br />

<br />

To accept the default location, click OK on the Administrative Settings dialog box. You will<br />

be prompted to create the default directory if it does not already exists.<br />

The default location of is:<br />

Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>NaturallySpeaking</strong>9\RoamingUsers\\<br />

The is the name you defined for the Master Roaming User location. You can have multiple


35<br />

multiple network storage locations for your Master Roaming User files.<br />

The are the names of the individual Master Roaming Users.<br />

Changing the default location<br />

1. Use the Browse for Folder dialog box to open a location where you want to store the master roaming user.<br />

This is the location on the computer where changes made during a dictation session, such as corrections or<br />

new acoustic data are stored before they are synchronized with the master roaming user.<br />

2. If the directory does not currently exist, click Make New Folder and type a name for the new folder. The<br />

new directory can have any name, but calling it something meaningful, such as Local Roaming User, will<br />

make the folder easier to find in the future.<br />

3. Click OK.<br />

Step 6: Set the Roaming User options<br />

The Administrative Settings dialog box also contains several options that affect how the Roaming User feature<br />

works. You can select from among the following options to modify the behavior of a roaming user for each<br />

Roaming User location:<br />

Allow non-Roaming Users to be opened<br />

Select this box to permit the user to open non-Roaming (local) users. Clear this option to prevent anyone<br />

from dictating with a non-Roaming (local) user by accident.<br />

Access network at user open/close only<br />

Select this box to synchronize changes made during a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> session from the Local<br />

Roaming User to the Master Roaming User only when <strong>Dragon</strong> <strong>NaturallySpeaking</strong> opens or closes. Otherwise,<br />

synchronization will occur each the user switches users, closes a user, or saves a user. For more information,<br />

see Synchronizing Master and Local Roaming Users. If you experience excessive network slowdowns,<br />

checking this option may solve the problem by limiting the times the Local and Master Roaming users are<br />

synchronized.<br />

Ask before breaking locks on network users (recommended for UNC and mapped drives)<br />

Select this box to keep the option of maintaining or breaking a network lock when opening a Roaming User.<br />

Normally, network locks prevent anyone from opening a Roaming User at the same time someone else is<br />

opening that user. While this process does not take a long time, network problems can cause a lock to<br />

become "stuck" and not release when the open process is completed. When this happens, the next time<br />

anyone tries to open that user, they will see a message informing them of the lock and giving them the<br />

option of overriding it. If you do not wish anyone to be bothered by this message and always want to break<br />

a network lock in this situation, you can clear this option to prevent the message from appearing. Because<br />

the presence of a lock can indicate a problem that needs to be addressed, Nuance recommends that you<br />

enable this option.<br />

Note: This option is valid for users connecting to the Master Roaming User location using a mapped drive or<br />

UNC drive. This option is not supported for users connecting over HTTP.<br />

Set audio levels on each machine (recommended)<br />

Select this box to run the "Check your audio settings" option from the Accuracy Assistant window before<br />

each dictation session with a Roaming User. This includes the Volume Check and the microphone Quality


36<br />

Check. Check this option if your users are users are using different machines or use a single machine, like<br />

a laptop, in many different locations. When a user changes machines or locations, the audio setup data can<br />

vary depending on differences in the microphone and sound card, as well as differences in ambient sound<br />

levels of each Roaming User location. In situations where <strong>Dragon</strong> <strong>NaturallySpeaking</strong> detects a significant<br />

difference between operating systems, sound cards, microphones, or other hardware, the program will<br />

prompt you to run "Check your audio settings" even if you do not have this option selected.<br />

Copy <strong>Dragon</strong> Log to Network<br />

Select this box to copy the file, <strong>Dragon</strong>.log from the local Roaming User location to the master Roaming<br />

User location at the same time that the program synchronizes the local and the master Roaming User.<br />

<strong>Dragon</strong>.log contains information that can help to diagnose problems that you might encounter using <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>.<br />

Note: If you set the "Disk space reserved for network archive" option, the <strong>Dragon</strong>.log file will not be<br />

copied once the maximum size is reached.<br />

Always copy acoustic information to network<br />

Select this box to copy the user's acoustic information to the Master Roaming User location. The Local<br />

Roaming User acoustic information is stored in:<br />

Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>NaturallySpeaking</strong>9\RoamingUsers\\\current\voice<br />

The is the name you defined for the Master Roaming User location. You can have multiple<br />

multiple network storage locations for your Master Roaming User files.<br />

The are the names of the individual Master Roaming Users.<br />

If you chose not to copy the user's acoustic information to the network, corrections you make on one<br />

machine will not be available on other machines used by that particular Roaming User until you run the<br />

Acoustic and Language Model Optimizer on the Master Roaming User location and the Local and Master<br />

Roaming user synchronize. Always copying the acoustic information to the Master Roaming User location<br />

means that these corrections are always available and will by automatically synchronized when the Master<br />

Roaming User is opened from another location.<br />

The transfer of acoustic information is not limited by setting the "Disk space reserved for network archive"<br />

option.<br />

Conserve archive size on network<br />

Select this box to prevent the copying .DRA files (files which contain the acoustic data from the latest<br />

dictation session) to the Master Roaming User location when the program synchronizes the Local and Master<br />

Roaming users. Leaving this box unchecked allows the local .DRA files to synchronize with the Master<br />

Roaming User. This makes the .DRA files available to the Acoustic and Language Model Optimizer when it is<br />

run on the Master Roaming User locations and means increased accuracy.<br />

However, .DRA files can be large. If you experience excessive network slowdowns, checking this option may<br />

solve the problem by eliminating the copying of this files each time the Master and Local Roaming users<br />

synchronize. You can still run the Acoustic and Language Model Optimizer on the Master Roaming User, but


37<br />

since it will be less efficient since it will not have the .DRA files to process.<br />

Note: If you set the "Disk space reserved for network archive" option, the .DRA files will not be copied once<br />

the maximum size is reached.<br />

Disk space reserved for network archive<br />

Notes:<br />

Use this option to specify the maximum size of the directory containing the acoustic data available to the<br />

Acoustic Optimizer. By default the archive size is 500MB. To conserve space, you can reduce the default size<br />

and select the "Conserve archive size on network" option. For this option to work, the machine you are<br />

setting it for must be connected from the network.<br />

� To enable Roaming Users and set the Roaming User options, you must start <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from<br />

an account with Windows Administrator privileges.<br />

� Once you set up an installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to use the Roaming User feature, users on that<br />

machine can only open Roaming Users; they cannot open any locally created users.<br />

� If you use variety of microphones or input devices with your roaming user, see Using multiple dictation<br />

sources with a single user for more information .<br />

� If you are dictating with a Roaming User, the Acoustic and Language Model Optimizer Scheduler is disabled on<br />

the local user's machine. You must run the Acoustic and Language Model Optimizer on the machine where<br />

your Master Roaming User files are located. For more information, see Running the Acoustic and Language<br />

Optimizer with a Roaming User.<br />

Roaming User Network Location<br />

You use the Roaming User Network Location dialog box to define the network location of the master roaming<br />

users.<br />

The location you pick must be accessible to all computers where users will dictate using a Roaming User.<br />

Display Name<br />

Sets the directory name displayed in the following locations:<br />

� The Roaming tab of the Admistrative Settings dialog box<br />

� The "Location of user files" field on the Open User.<br />

Note: With the Roaming User enabled, the Open User dialog box displays only users in the Roaming User<br />

locations. To let the users open both local (non-roaming) and Roaming users, select the "Allow<br />

non-roaming users to be opened" option on the Administrative Settings dialog box. Clearing this option<br />

prevents users from dictating with a non-roaming (local) user by accident. For more information, see<br />

Setting Up the Roaming User feature..<br />

� The "Location of user files" field on the Manage Users dialog boxes.<br />

Network Location<br />

On each computer where you plan to have users dictating as a Roaming Users, you must tell that installation


38<br />

of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> where the Master Roaming user is located.<br />

The Roaming User feature supports the following types of locations:<br />

Mapped Drives and UNC Paths<br />

Mapped drives connect to a shared network folder that has a drive letter assigned to it.<br />

UNC paths connect to a shared network folder using the Universal Naming Convention (UNC) to locate a user.<br />

The UNC is a way to identify a shared file on a computer or network without having to know the storage device<br />

it is on. The UNC path format is: \\servername\sharename\path\filename.<br />

To use a mapped drive or UNC path:<br />

1. Under Network Location, enter the address of the mapped drive or UNC path.<br />

You can click Browse to browse for the location of the mapped drive or UNC path. This displays the Browse<br />

for Folder dialog box. You can also create a new directory on the mapped drive or UNC path by clicking the<br />

Make New Folder button.<br />

2. Click OK when you are done.<br />

Intranet/Internet connections<br />

1. Under Network Location, enter the URL address of your HTTP server where your roaming user master files<br />

are located.<br />

2. Click the HTTP Settings... button to display the HTTP Settings dialog box.<br />

From the HTTP Settings dialog box, you can set information specific to your HTTP connection like<br />

Authentication, Firewall, and Proxy Server information. You can also test your connection to the HTTP<br />

server from HTTP Settings dialog box. For more information, see HTTP Settings.<br />

After specifying the HTTP Settings, use the Test Connection button to make sure your settings are correct.<br />

For more information<br />

About the Roaming User feature<br />

Setting up the Roaming User feature<br />

Creating and opening a roaming user<br />

Internet Roaming User Guidelines<br />

On each computer where you plan to have users dictating as a Roaming Users, you must tell that installation<br />

of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> where the Master Roaming user is located.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> lets you store you Master Roaming Users on an HTTP server; allowing you to access<br />

your Master Roaming Users over the internet.


39<br />

To connect to an HTTP server, you must suppy the following information:<br />

� The network location: You use the Roaming User Network Location dialog box to define the network location<br />

of the master roaming users. You must supply the URL address of your HTTP server where your roaming user<br />

master files are located. For more information, see Roaming User Network Location.<br />

� HTTP settings: From the HTTP Settings dialog box, you can set information specific to your HTTP connection<br />

like Authentication, Firewall, and Proxy Server information. For more information, see HTTP Settings.<br />

Supported Servers<br />

Internet Roaming is supported on:<br />

� Microsoft Internet Information Services (IIS) 6.0<br />

� Apache HTTP Server 2.0.54 and higher<br />

Testing the HTTP connection<br />

Once you have supplied all the necessary information needed to connect to your HTTP server, press the Test<br />

Connection button. The Test Connection button tests the connection to your HTTP server bases in the<br />

information you supplied in the Roaming User Network Location HTTP Settings dialog box.<br />

Troubleshooting test connections<br />

The following table lists the possible messages you can recieve after pressing the Test Connection button.<br />

Message Solution<br />

Connection test successful! None - test successful.<br />

Could not connect to the network location. � Check spelling and syntx of the HTTP address in the HTTP<br />

Settings dialog.<br />

� Check your local network for problems.<br />

Could not copy a file to the network location � Check create and write privileges on the server<br />

Could not create a directory on the network<br />

location<br />

Could not delete a file from the network<br />

location<br />

Could not delete a directory from the<br />

network location<br />

Could not copy files into a directory created<br />

on the network location<br />

� Server not installed or active.<br />

� Check the create directory privileges on the server for the<br />

Master Roaming directory.<br />

� Check the the privileges for creating sub-directories under the<br />

Master Roaming directory.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges.<br />

� Check for authentication time-out on your server.<br />

� Check your local network for problems.


Could not list the contents of a directory<br />

created on the network location<br />

Contents of newly created directory<br />

TempDir were incorrect<br />

Could not copy a file from the network<br />

location<br />

Could not get the size of a newly created<br />

directory on the network location.<br />

Could not rename a file on the network<br />

location<br />

Could not rename a directory on the network<br />

location<br />

Could not copy a directory within the<br />

network location<br />

Creating a Roaming User<br />

40<br />

There are three ways to create a Roaming User:<br />

� Train a new Roaming User<br />

� Convert a non-roaming local user into a Roaming User<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

Caused by an incomlete directory listing. Try again. If the<br />

problem persists, check the condition of your network.<br />

� Check permissions on the Local Master Roaming directory.<br />

� Check that the Local Master Roaming directory exists.<br />

Apache: Make sure DavDepthInfinity directive is set to "on" for<br />

Master Roaming directory.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

� Check permissions on the Master Roaming directory. The user<br />

must have read, write, and modify privileges<br />

� Check that privileges are inherited in the subdirectories.<br />

� Copy an non-roaming local users to the Master Roaming User location.<br />

To open or create Roaming User, your local installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> must be configured for<br />

Roaming Users. For more information, see Setting up the Roaming User Feature.<br />

To create and train a new Roaming User<br />

1. Make sure that no local user is open. Click <strong>NaturallySpeaking</strong>>Close User on the <strong>Dragon</strong>Bar if one is open.<br />

2. Select <strong>NaturallySpeaking</strong>>Open Users on the <strong>Dragon</strong>Bar. This displays the Open User dialog box. If you do<br />

not see the user you are looking for, hit F5 to refresh the list of users.<br />

Note: When the Roaming User feature is enabled, you can only create Roaming Users. The "Location of<br />

user files" field only display the Roaming User locations you defined in the Administrative Settings dialog<br />

box. To let the users create both local (non-roaming) and Roaming Users, select the "Allow non-Roaming<br />

Users to be opened" option on the Administrative Settings dialog box. Clearing this option prevents users<br />

from dictating with a non-roaming local user by accident. For more information, see Setting up the<br />

Roaming User Feature.


41<br />

If you allow users to select both non-roaming local and Roaming Users, make sure they select the correct<br />

location from the "Location of user files" field.<br />

3. Click New and begin training the user as you would any other user. When you are finished training the user,<br />

the program copies the user files into the master Roaming User location specified in the "Location of user<br />

files" field.<br />

To convert a non-roaming local user into a Roaming User<br />

You can convert an existing non-roaming local user to a Roaming User from the Manage Users dialog box.<br />

Converting a non-roaming local user copies that user to the specified Master Roaming User location.<br />

1. Make sure that no local user is open. Click <strong>NaturallySpeaking</strong>>Close User on the <strong>Dragon</strong>Bar if one is open.<br />

2. Select <strong>NaturallySpeaking</strong>>Manage Users from the <strong>Dragon</strong>Bar. This displays the Manager User Dialog box.<br />

3. Select the non-roaming local location of your user files from the "Location of user files" field. This should<br />

display the list of non-roaming local users that you can convert to Master Roaming Users.<br />

4. Select the non-roaming local user you want to convert to a Master Roaming User.<br />

5. Click the Advanced button and then click Save to Roaming. This displays the Save to Roaming dialog box.<br />

6. Select the appropriate Master Roaming User location and click OK. A Master Roaming User location<br />

appears in this list only if it is currently connected to the local machine.<br />

7. Repeat the process for any other non-roaming local users you want to convert to Master Roaming Users.<br />

To copy a user into the master user location<br />

You can also copy a non-roaming local user into the network directory of the Master Roaming User. This has the<br />

advantage of allowing you to turn a number of non-roaming local users into master Roaming Users with a single<br />

operation.<br />

Notes:<br />

1. Navigate to the location of the non-roaming local user files you want to convert to Master Roaming Users.<br />

2. Select the files non-roaming local users you want to copy.<br />

3. Copy the selected non-roaming local users to the Master Roaming User network directory.<br />

• By default, non-roaming local users are located in:<br />

C:\Documents and Settings\All Users\Application Data\Nuance\<strong>NaturallySpeaking</strong>9\Users<br />

• Each non-roaming local user has it's own directory structure. Make sure to copy the entire user directory<br />

structure to the Master Roaming User network directory.<br />

To open a Roaming User<br />

1. Make sure that no local user is open. Click <strong>NaturallySpeaking</strong>>Close User on the <strong>Dragon</strong>Bar if one is open.<br />

2. Select <strong>NaturallySpeaking</strong>>Open Users on the <strong>Dragon</strong>Bar. This displays the Open User dialog box. If you do<br />

not see the user you are looking for, hit F5 to refresh the list of users.<br />

If you allow users to select both non-roaming local and Roaming Users, make sure they select the correct


Notes<br />

42<br />

location from the "Location of user files" field.<br />

Notes:<br />

o When the Roaming User feature is enabled, you can only open Roaming Users. The "Location of<br />

user files" field only display the Roaming User location you defined in the Administrative Settings<br />

dialog box. To let the users open both local (non-roaming) and Roaming Users, select the "Allow<br />

non-Roaming Users to be opened" option on the Administrative Settings dialog box. Clearing this<br />

option prevents users from dictating with a non-roaming local user by accident. For more<br />

information, see Setting up the Roaming User Feature.<br />

o If you connect to your Roaming User Master Directory over HTTP, and you find that not all your<br />

users are listed in the Open User dialog box, make sure that:<br />

� The .INI extention is registered in MIME types (ini.png) list of your IIS server<br />

� The user's topics.ini file is not locked, password protected, or otherwise restricted for<br />

access by your server permissions.<br />

3. Select a user and click Open.<br />

� If you use variety of microphones or input devices with your Roaming User, see the topic: Using multiple<br />

dictation sources with a single user.<br />

� When you export a user to a new location, any custom words that you have added to a local Roaming User will<br />

not accompany the user files unless you first run Add Words from Document wizard from the Accuracy Center.<br />

As an alternative to running the Add Words from Document wizard, you can turn the Roaming User feature off<br />

on the Administrative Settings dialog box, save the user, and then turn the feature back on.<br />

� If you modify a master Roaming User while you have a local Roaming User open on a computer that is not<br />

currently connected to the network (for example, a laptop at a remote location), the changes to the master<br />

Roaming User will overwrite any changes you make to the local Roaming User when you synchronize the local<br />

and master Roaming Users.<br />

� When a Roaming User exits <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, switches users, closes a user, or saves a user, <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> saves changes to the Local Roaming User and then synchronizes these changes with the<br />

Master Roaming User on the network. For more information, see Synchronizing Master and Local Roaming<br />

Users<br />

Using multiple dictation sources with a single user<br />

It is possible to use a variety of dictation sources with a single set of user files such as different microphones<br />

or portable recording devices. This ability is especially useful with a Roaming User. By allowing multiple<br />

dictation sources, you can still have the same user files for each location regardless of the microphone type or<br />

differences in ambient noise.<br />

You can add dictation sources to a user in the following way:<br />

To add a new dictation source to a user<br />

1. On the Open User dialog box, select the User for which you want to create a new dictation source.


43<br />

2. Click the Source button and then click New. This displays the the New Dictation Source dialog box.<br />

3. Select a new input device for your dictation from the list on the New Dictation Source dialog box. For example,<br />

you can choose from among different microphone or recorder types.<br />

4. Click OK. You return to the Open User dialog box.<br />

5. Select the user you just created and click Open. If you have not previously trained the user with the new<br />

dictation source, the New User wizard appears and you can begin training.<br />

Running the Acoustic and Language Model Optimizer for Roaming Users<br />

When a Local Roaming User is open, that user cannot run the Acoustic and Language Model Optimizer or the<br />

Acoustic and Language Model Optimizer Scheduler. The Acoustic and Language Model Optimizer can only be<br />

run on the Master Roaming User. In this way, any optimizations done by the Acoustic and Language Model<br />

Optimizer are copied to with each Local Roaming User when synchronization occurs.<br />

The system administrator is responsible for running the Acoustic and Language Model Optimizer on the<br />

network location of the Master Roaming Users. The administrator can install <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the<br />

machine where the Master Roaming User files are located or an any machine that has network access to the<br />

Master Roaming User files and run the Scheduler for the Acoustic and Language Model Optimizer.<br />

Note: You must have Windows Administrator privileges on the machine where you are running the Scheduler<br />

for the Acoustic and Language Model Optimizer.<br />

To run the Acoustic and Language Model Optimizer to optimize Roaming Users<br />

1. Be sure that a copy of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> is installed on the computer where you plan to run the<br />

Acoustic and Language Model Optimizer.<br />

2. On the Windows Start menu, select Programs><strong>Dragon</strong> <strong>NaturallySpeaking</strong> 9.0><strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

Tools>Scheduler for Acoustic and Language Model Optimizer to start the Acoustic and Language Model<br />

Optimizer Scheduler.<br />

3. Access the master directory of the Roaming Users you want to optimize. To do this, click Set Speaker<br />

Directory on the File menu of the Acoustic and Language Model Optimizer Scheduler window. On the Set<br />

User Profile Directory dialog box, either enter the path of the directory or click the Browse button. If the<br />

users you want to optimize are located in multiple directories, you can change directories to locate the<br />

additional users.<br />

4. Select the user or users you want to optimize and set a schedule for running the Acoustic and Language<br />

Model Optimizer. Consult the Help for Using the Acoustic and Language Model Optimizer Scheduler for<br />

specific instructions.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Data Distribution Tool<br />

Overview<br />

You use the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Data Distribution Tool when you want to interactively make new words,<br />

customized vocabularies or new commands available to all user profiles on a particular <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

installation. You run the Data Distribution Tool on each <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation where you want the


new words or vocabularies to be available to your <strong>Dragon</strong> <strong>NaturallySpeaking</strong> users.<br />

This section describes:<br />

44<br />

• Using the Data Distribution Tool<br />

• Adding Custom Words<br />

• Adding and Deleting Custom Vocabularies<br />

• Adding Custom Commands<br />

You can also run nsadmin from the command line. For more information, see Nsadmin command line.<br />

Note: The <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Data Distribution Tool only runs on <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Professional<br />

and higher editions.<br />

Using the Data Distribution Tool<br />

You use Data Distribution Tool when you want to interactively make new words, customized vocabularies or new<br />

commands available to all user profiles on a particular <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation.<br />

You run the Data Distribution Tool on each <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation where you want the new words<br />

or vocabularies to be available to your <strong>Dragon</strong> <strong>NaturallySpeaking</strong> users.<br />

Note: Both mapped drives and UNC paths are supported.<br />

Starting the Data Distribution Tool<br />

To start Data Distribution Tool , select Start > All Programs > <strong>Dragon</strong> <strong>NaturallySpeaking</strong> > Tools > Data<br />

Distribution Tool<br />

This displays the first screen of the nsadmin wizard. From this screen, you can:<br />

• Add or remove base vocabularies<br />

• Add or remove shared commands<br />

• Add or remove word to share across vocabularies<br />

Select an operation and click Next,<br />

Advanced<br />

Click the Advanced button to set the location where the local installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> stores<br />

cutomized words and commands.<br />

For a default installation, custom commands for existing DNS users are located in:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>\Custom\


Data Distribution Tool : Add and removing custom words<br />

You can use the Data Distribution Tool to make new words available to all user profiles on a particular installation.<br />

To distribute a set of custom words (for example, a list of new drug names) to a particular installation, you must<br />

first either:<br />

Notes<br />

45<br />

• Create a text (.txt) file and enter each word or phrase you want to add to the vocabulary on a separate line.<br />

Make sure words are spelled correctly. Each word, phrase or name that you add must be on a separate line.<br />

To add a multiple-word phrase, such as "Mayberry Tribune," enter it on one line.<br />

To include a spoken form for a word, type the word followed by a backslash (\) and the spoken form. For<br />

example, to have "Robert F. Kennedy" entered when you say "RFK" type Robert F. Kennedy\RFK.<br />

• If you have <strong>Dragon</strong> <strong>NaturallySpeaking</strong> available on another machine, you can use it to create those words<br />

and export the words to a .txt file. For more information, see your DNS documentation.<br />

• After you have have imported the custom words using nsadmin, you must close your users, then re-open<br />

and save them for the changes to become available.<br />

• Paths can be entered as complete local paths, relative paths, mapped network drives, a UNC path, or the<br />

path to removable media, such as a CD-ROM or ZIP drive. Pathnames that include spaces must be<br />

enclosed in quotation marks.<br />

Before adding the custom words<br />

Once you have created a .txt file (newwords.txt in the following examples) containing the custom words:<br />

1. Copy the .txt file to a shared location accessible to all the client computers where you want to add the<br />

words.<br />

2. On each client computer, map a network drive to the shared location you created or reference the network<br />

UNC address of the location in the nsadmin program.<br />

Adding custom words<br />

To add custom words:<br />

1. Select "Add or remove words to share across vocabularies" from the Data Distribution Tool and click Next.<br />

2. Select the languages of the user profiles that will have the custom words added and click Next.<br />

3. Use the Import button to select the .TXT files containing the custom words you want to add.<br />

You can use the View button to view the files that you added. You can modify the list by using the Remove<br />

and Remove All buttons.<br />

Click Next to continue.<br />

4. The Data Distribution Tool displays a log of all operations it performed.<br />

5. Click Finish when to re-display the Data Distribution Tool main screen; click Cancel to exit..<br />

The NewWords.txt file will be copied to the following directory on each machine where it is run:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\enx\NewWords.txt


Data Distribution Tool : Adding and removing vocabularies<br />

You can use Data Distribution Tool to make a customized vocabulary available to all user profiles on a particular<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation.<br />

For example, say you have extensively customized a vocabulary using the Voctool. Using the Data Distribution<br />

Tool , you can copy the user's vocabulary to be used as a base vocabulary on any <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

installation. By adding a base vocabulary to a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation, any user profiles created<br />

after adding that vocabulary can use that vocabulary.<br />

Notes<br />

46<br />

• For a default installation, vocabularies for existing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> users are located in:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\users\\current<br />

• Vocabulary files end with the *.voc extension.<br />

Before adding a vocabulary<br />

Before adding the new vocabulary with the Data Distribution Tool :<br />

• Copy the vocabulary to a shared location accessible to all the client computers where you want to add the<br />

vocabulary.<br />

• On each client computer where you plan to add the vocabulary, map a network drive to the shared location<br />

you created or reference the network UNC address of the location in the nsadmin command.<br />

Adding a vocabulary<br />

To add a new base vocabulary:<br />

1. Select "Add or remove base vocabulary" from the Data Distribution Tool and click Next.<br />

2. On the screen click "Add". This displays the Add Base Vocabulary dialog.<br />

3. On the Add Base Vocabulary dialog box:<br />

o Give the vocabulary a name. The name should describe the content of the vocabulary, such as<br />

"Astronomy" or "Marketing."<br />

o Select the location of the vocabulary. This can be either a mapped drive or UNC address<br />

o Give the vocabulary an unique numeric ID. Use a value greater than 9000 for the topic ID<br />

parameter.<br />

4. Click OK when you are done.<br />

Adding exported vocabularies<br />

If you used a separate installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to create a vocabulary, you can use the Data<br />

Distribution Tool to distribute that vocabulary.<br />

An exported <strong>Dragon</strong> <strong>NaturallySpeaking</strong> vocabulary is saved as a group of files.


One of the exported files has a .top file extension, the other files have .to* file extensions, where * is an integer.<br />

To add an exported vocabulary to <strong>NaturallySpeaking</strong> with the Data Distribution Tool , provide the path to the file<br />

with the .top file extension as an argument on the nsadmin command line.<br />

For information on exporting a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> vocabulary, see open_voc_dialog.htm<br />

Deleting a vocabulary<br />

To delete a base vocabulary:<br />

47<br />

1. Select "Add or remove base vocabulary" from the Data Distribution Tool and click Next.<br />

2. The screen displays the existing base vocabularies by ID and username.<br />

3. Select the vocabulary to delete.<br />

4. Click Remove and then click Next. The Data Distribution Tool displays message when the vocabulary is<br />

deleted.<br />

5. Click Finish to close the Data Distribution Tool or back to re-display the screen.<br />

Data Distribution Tool: Adding and removing custom commands<br />

You can use the Data Distribution Tool to make a set of custom commands available to all user profiles on a<br />

particular DNS installation.<br />

Note the following when adding a custom commands:<br />

• For a default installation, custom commands for existing DNS users are located in:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>\Custom\<br />

• Once you have imported the custom commands to <strong>NaturallySpeaking</strong> installation, you must close your<br />

users, then re-open and save them for the changes to become available to those users.<br />

Before adding the commands<br />

Custom commands are voice commands that you can create and modify to enter text, insert graphics, or activate<br />

menu and keystroke commands in any application. You can create these commands with the MyCommands editor<br />

or modify commands using the Command Browser.<br />

When creating commands for export:<br />

1. Create custom commands in <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

2. Export the commands to a .dat file using the Command Browser.<br />

3. Copy the .dat file to a shared location accessible to all the client computers where you want to add the<br />

commands.<br />

Adding custom commands<br />

To add custom commands:


48<br />

1. Select "Add or remove shared commands " from the Data Distribution Tool and click Next.<br />

2. Select the languages of the user profiles that will have the custom words added and click Next.<br />

3. Use the Import button to select the .DAT files containing the custom commands you want to add.<br />

You can modify the list by using the Remove and Remove All buttons.<br />

Click Next to continue.<br />

4. The Data Distribution Tool displays a log of all operations it performed.<br />

5. Click Finish when to re-display the Data Distribution Tool main screen; click Cancel to exit..<br />

Removing shared commands<br />

To remove shared commands:<br />

Paths<br />

3. Select "Add or remove shared commands " from the Data Distribution Tool and click Next.<br />

4. Select the languages of the user profiles that will have the custom words added and click Next.<br />

5. Select the command to remove from the "Existing shared commands" list and click Remove.<br />

6. Click Next. The Data Distribution Tool displays a log of all operations it performed.<br />

7. Click Finish when to re-display the Data Distribution Tool main screen; click Cancel to exit..<br />

Paths can be entered as complete local paths, relative paths, mapped network drives, a UNC path, or the path to<br />

removable media, such as a CD-ROM or ZIP drive. Pathnames that include spaces must be enclosed in quotation<br />

marks.<br />

For example, if the .dat file is named NewCommands.dat, The NewCommands.dat file will be copied to::<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\enx\NewCommands.dat<br />

Nsadmin command line<br />

You use nsadmin command line when you want to make new words, customized vocabularies or new commands<br />

available to all user profiles on a particular <strong>Dragon</strong> <strong>NaturallySpeaking</strong> installation.<br />

The nsadmin command line only performs one operation at a time, but you can write your own batch file or script<br />

to execute multiple nsadmin operations on each computer.<br />

This section describes:<br />

• Using the nsadmin command line<br />

• Adding Custom Words<br />

• Adding and Deleting Custon Vocabularies


49<br />

• Adding Custom Commands<br />

You can also run nsadmin interactively. For more information, see Using the Data Distribution Tool.<br />

Note: The nsadmin command line utility only runs on <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Professional and higher editions.<br />

Using nsadmin<br />

You run the nsadmin utility on each computer containing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> where you want the new words,<br />

vocabularies, or commands to be available.<br />

The nsadmin program only performs one operation at a time, but you can write your own batch file or script to<br />

execute multiple nsadmin operations on each computer.<br />

Starting nsadmin<br />

To start nsadmin, select Start > All Programs > <strong>Dragon</strong> <strong>NaturallySpeaking</strong> > Tools > Nsadmin<br />

Nsadmin starts in a DOS window, listing the nsadmin syntax. To re-display the nsadmin syntax, enter the<br />

following:<br />

>nsadmin /?<br />

The nsadmin.exe program is located in the \Program directory beneath the directory where NaturuallySpeaking is<br />

installed. For example, in a default installation:<br />

C:\Program Files\Nuance\<strong>Dragon</strong> <strong>NaturallySpeaking</strong>9\Program><br />

Command line syntax<br />

The nsadmin.exe program uses the following syntax.<br />

nsadmin [options]<br />

Available commands and options:<br />

Commands and parameters Description<br />

/commands Adds a command file to the local installation<br />

/words Adds a list of new words to the local installation<br />

/vocabulary " | |<br />

" <br />

Adds a vocabulary contained in or an exported .top<br />

file to the <strong>NaturallySpeaking</strong> using the specified , and <br />

/vocabulary delete Deletes the base vocabulary specified by <br />

Options<br />

/language enx | fra | deu | ita | esp | nld<br />

Name of an installed <strong>NaturallySpeaking</strong> language to which you want<br />

to add words, commands, or a vocabulary. The default value is "enx."


overwrite yes | no | ask<br />

/? Display the command syntax<br />

Notes:<br />

50<br />

Specifies overwrite rules if a file exists with the same name as the file<br />

you are attempting to add. The default value is "ask."<br />

• Command line arguments that contain spaces must be enclosed in quotation marks.<br />

• If you are running nsadmin from other than the DNS Tools, you must specify the full path to the<br />

nsadmin.exe program on the command line.<br />

• You may want to write a batch file or script that executes nsadmin. When you have new words or<br />

vocabularies to distribute, you can place them at the network location defined in the script and run the<br />

script from the client machines to copy the new functionality to those machines.<br />

• Both mapped drives and UNC paths are supported.<br />

nsadmin: Adding custom words<br />

You can use nsadmin to make new words available to all user profiles on a particular installation.<br />

To distribute a set of custom words (for example, a list of new drug names) to a particular installation, you must<br />

first either:<br />

Notes<br />

• Create a text (.txt) file and enter each word or phrase you want to add to the vocabulary on a separate line.<br />

Make sure words are spelled correctly. Each word, phrase or name that you add must be on a separate line.<br />

To add a multiple-word phrase, such as "Mayberry Tribune," enter it on one line.<br />

To include a spoken form for a word, type the word followed by a backslash (\) and the spoken form. For<br />

example, to have "Robert F. Kennedy" entered when you say "RFK" type Robert F. Kennedy\RFK.<br />

• If you have <strong>Dragon</strong> <strong>NaturallySpeaking</strong> available on another machine, you can use it to create those words<br />

and export the words to a .txt file. For more information, see your DNS documentation.<br />

• After you have have imported the custom words using nsadmin, you must close your users, then re-open<br />

and save them for the changes to become available.<br />

• Paths can be entered as complete local paths, relative paths, mapped network drives, a UNC path, or the<br />

path to removable media, such as a CD-ROM or ZIP drive. Pathnames that include spaces must be<br />

enclosed in quotation marks.<br />

Adding custom words<br />

Once you have created a .txt file (newwords.txt in the following examples) containing the custom words:<br />

1. Copy the .txt file to a shared location accessible to all the client computers where you want to add the<br />

words.<br />

2. On each client computer, map a network drive to the shared location you created or reference the network


51<br />

UNC address of the location in the nsadmin program.<br />

3. On each client computer, use the following command to add the custom words contained in the .txt file.<br />

\nsadmin /words G:\NsAdmin\NewWords.txt<br />

The NewWords.txt file will be copied to the following directory on each machine where it is run:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\enx\NewWords.txt<br />

Example: Overwriting a custom words file<br />

To overwrite a custom words file with the same name as the file you are adding, use the /overwrite option:<br />

\nsadmin /words G:\NsAdmin\NewWords.txt /overwrite=yes<br />

If the NewWords.txt file already exists in the \Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>Dragon</strong> <strong>NaturallySpeaking</strong>9\Custom\enx directory, the new file will overwrite the existing<br />

file without prompting you.<br />

nsadmin: Adding and Deleting Custom Vocabularies<br />

You can use nsadmin to make a customized vocabulary available to all user profiles on a particular DNS installation.<br />

For example, say you have extensively customized a vocabulary using the Voctool. Using nsadmin, you can copy<br />

the user's vocabulary to be used as a base vocabulary on any DNS installation. By adding a base vocabulary to a<br />

DNS installation, any user profiles created after adding that vocabulary can use that vocabulary.<br />

Note the following when adding a custom vocabulary:<br />

• For a default installation, vocabularies for existing DNS users are located in:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\users\\current<br />

• Copy the directory containing the vocabulary to a shared location accessible to all the client computers<br />

where you want to add the vocabulary.<br />

Adding vocabularies<br />

Notes<br />

1. Copy the vocabulary to a shared location accessible to all the client computers where you want to add the<br />

words.<br />

2. On each client computer, map a network drive to the shared location you created or reference the network<br />

UNC address of the location in the nsadmin command.<br />

3. On each client computer, use the following command syntax to add the vocabulary:<br />

\nsadmin /vocabulary " | |<br />

" <br />

• Use the parameter to link a vocabulary to a language.


52<br />

For example, "US English" or "UK English" for an English install. The language or dialect you enter must be<br />

present in the version of <strong>NaturallySpeaking</strong> installed on the computer. The represents the<br />

size of the vocabulary you are importing.<br />

• The value you specify for the parameter should describe the content of the vocabulary, such<br />

as "Astronomy" or "Marketing."<br />

• Use a value greater than 9000 for the topic ID parameter.<br />

Example<br />

\nsadmin /vocabulary G:\NsAdmin\myvoc "US English | Large | Nuance" 9005<br />

The contents of the myvoc directory will be copied to:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\enx\Custom9005\<br />

The model name, category, and ID will be added to the models.ini file.<br />

To overwrite a vocabulary with the same name as the vocabulary you are adding, use the<br />

/overwrite option:<br />

\nsadmin /vocabulary G:\NsAdmin\myvoc "US English | Large | Nuance" 9005<br />

/overwrite=yes<br />

If the vocabulary file already exists in \Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>Dragon</strong> <strong>NaturallySpeaking</strong>9\Custom\enx\Custom9005\, it will be overwritten without<br />

prompting you.<br />

Adding exported vocabularies<br />

If you used a separate installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to create a vocabulary, you can use nsadmin to<br />

distribute that vocabulary.<br />

An exported <strong>Dragon</strong> <strong>NaturallySpeaking</strong> vocabulary is saved as a group of files.<br />

One of the exported files has a .top file extension, the other files have .to* file extensions, where * is an integer.<br />

To add an exported vocabulary to <strong>NaturallySpeaking</strong> with nsadmin, provide the path to the file with the .top file<br />

extension as an argument on the nsadmin command line. Do NOT include the .top file extension on the command<br />

line.<br />

The following command adds the "myvoc" exported topic (myvoc.top) as a new base vocabulary.<br />

\nsadmin /vocabulary D:\MyDocuments\myvoc "US English | Large | Nuance" 9005<br />

Deleting a base vocabulary<br />

On each client computer, use the following command syntax to delete the vocabulary and the corresponding entry<br />

in models.ini:<br />

\nsadmin /vocabulary delete <br />

\nsadmin /vocabulary delete 9005<br />

After a base vocabulary is deleted, no user's vocabularies based on that base vocabulary can be used.


nsadmin: Adding Custom Commands<br />

You can use nsadmin to make a set of custom commands available to all user profiles on a particular DNS<br />

installation.<br />

Note the following when adding a custom commands:<br />

53<br />

• For a default installation, custom commands for existing DNS users are located in:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>\Custom\<br />

• Once you have imported the custom commands to <strong>NaturallySpeaking</strong> installation, you must close your<br />

users, then re-open and save them for the changes to become available to those users.<br />

Adding custom commands<br />

1. Create custom commands in <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

2. Export the commands to a .dat file. In this example, NewCommands.dat.<br />

3. Copy the .dat file to a shared location accessible to all the client computers where you want to add the<br />

commands.<br />

4. On each client computer, map a network drive to the shared location you created or reference the network<br />

UNC address of the location with nsadmin.<br />

5. On each client computer, use the following command syntax to add the custom commands contained in<br />

the .dat file.<br />

Example<br />

\nsadmin /commands G:\NsAdmin\NewCommands.dat<br />

Paths<br />

Paths can be entered as complete local paths, relative paths, mapped network drives, a UNC path, or the path to<br />

removable media, such as a CD-ROM or ZIP drive. Pathnames that include spaces must be enclosed in quotation<br />

marks.<br />

To use a UNC address, format the command as in the following example:<br />

\nsadmin /commands \\HostComputer\NsAdmin\NewCommands.dat<br />

The NewCommands.dat file will be copied to::<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\enx\NewCommands.dat<br />

To add the commands to a language other than English, use the /language option:<br />

\nsadmin /commands G:\NsAdmin\NewCommands.dat /language=fra<br />

The NewCommands.dat file will be copied to:<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>9\Custom\fra\NewCommands.dat<br />

To overwrite a commands file with the same name as the file you are adding, use the<br />

/overwrite option:


\nsadmin /commands G:\NsAdmin\NewCommands.dat /overwrite=yes<br />

If the NewCommands.dat file already exists in the<br />

\Documents and Settings\All Users\Application Data\Nuance\<strong>Dragon</strong> <strong>NaturallySpeaking</strong>9\Custom\enx<br />

directory, the new file will overwrite the existing file without prompting you.<br />

Vocabulary Tool<br />

<strong>Dragon</strong> Vocabulary Tool (Voctool)<br />

You use the <strong>Dragon</strong> Vocabulary Tool to customize a vocabulary by adding new words and by optimizing the<br />

language model. This section includes:<br />

54<br />

• Vocabulary Tool Overview<br />

• Choosing Documents<br />

• Choosing Word Lists<br />

• Analyzing Settings<br />

• Analyzing Files<br />

• Previewing New Words<br />

• Training Added Words<br />

• Language Model Building<br />

• Summary Screen<br />

<strong>Dragon</strong> Vocabulary Tool: Overview<br />

The <strong>Dragon</strong> Vocabulary Tool allows you to customize a vocabulary by adding new words and by optimizing the<br />

language model.<br />

The following information is available and can be modified on the introduction screen of this wizard.<br />

User<br />

The name of the user that the <strong>Dragon</strong> Vocabulary Tool will modify.<br />

Vocabulary<br />

The vocabulary type from which the user was created.<br />

Change User/Vocabulary<br />

Click this button to open the Select Speaker dialog box. Use this dialog box to choose a different user from among<br />

the ones that are available.


Add new words from documents and adapt to writing style<br />

This option instructs the <strong>Dragon</strong> Vocabulary Tool to examine documents you specify in the Choose Documents<br />

screen that appears when you click Next. In general, you should select documents that reflect the preferred writing<br />

style and vocabulary of the person who will use the modified user files for dictation.<br />

Add new words from word list files<br />

This option instructs the <strong>Dragon</strong> Vocabulary Tool to examine files containing lists of words that you specify in the<br />

Choose Word Lists screen that appears when you click Next. Choosing this option means that the Vocabulary Tool<br />

will only add words and will not analyse word frequency or otherwise adapt the vocabulary to a particular writing<br />

style.<br />

Notes<br />

55<br />

• Do not change the current user or the vocabulary while you are running the <strong>Dragon</strong> Vocabulary Tool. If you<br />

do try to change the user or vocabulary, the <strong>Dragon</strong> Vocabulary Tool will stop running and discard any<br />

changes.<br />

• You can run the <strong>Dragon</strong> Vocabulary Tool using MS-DOS commands. To view a list of command-line<br />

switches for running the <strong>Dragon</strong> Vocabulary Tool, type "voctool.exe /?" at the prompt inside a<br />

command-prompt window.<br />

<strong>Dragon</strong> Vocabulary Tool: Choosing Documents<br />

In this step you select documents for the Vocabulary Tool to analyse. The Vocabulary Tool determines which words<br />

in the documents are not in the current vocabulary and analyses the frequency and order in which words appear<br />

in the samples to better understand the writing style of the author.<br />

The following information and buttons appear on this screen:<br />

Documents<br />

The list of documents that you can have the Vocabulary Tool analyse. The buttons to the right of this list allow you<br />

to add to and delete from the contents of the list.<br />

Add Folder<br />

Click this button to open the Browse for Folder dialog box, which you can use to select a folder of documents to<br />

display in the documents list. Continue to click the Add Folder button and select different folders to add additional<br />

documents to the list.<br />

Add Document<br />

Click this button to open the Add Documents dialog box, which you can use to select documents from a folder to<br />

display in the documents list. You can hold down the CTRL key and click individual document names to select<br />

multiple documents one at a time, or you can hold down the SHIFT key and click the first and last document names<br />

to select a range of documents. Continue to click the Add Documents button and select different folders to add<br />

additional documents to the list.<br />

Remove Document


Click this button to remove selected document names from the document list. You can hold down the CTRL key and<br />

click individual document names to select multiple documents one at a time, or you can hold down the SHIFT key<br />

and click the first and last document names to select a range of documents.<br />

View Document<br />

Click this button to open a selected document in the application in which the document was created. For example,<br />

if the document has a .doc extension, it will open in Microsoft Word. If the document has a .txt extension, it will<br />

open in Notepad. The application must be available on your computer for you to be able to view a document.<br />

Save List<br />

Click this button to open the Save Document List as File dialog box, which you can use to save the current list of<br />

documents in a separate file in the Folder of your choice. The files contains a .txt extension.<br />

Load List<br />

Click this button to open the Load Document List from File dialog box, which you can use to locate and load a file<br />

containing a list of documents from among those that have been previously saved. If the file you try to load is not<br />

an appropriate file list, an error message alerting you of this fact will appear and the contents of the file will not<br />

appear in the document list.<br />

Notes<br />

56<br />

• The <strong>Dragon</strong> Vocabulary Tool can process documents created in the following formats:<br />

o Microsoft Word (*.DOC)<br />

o Corel WordPerfect (*.WPD)<br />

o ASCII Text (*.TXT)<br />

o Rich Text Format (*.RTF)<br />

o HyperText (*.HTM, *.HTML, *.SHTM, and *.SHTML)<br />

If your computer does not have access to an application that can open a particular format, then the <strong>Dragon</strong><br />

Vocabulary Tool will not be able to process that document.<br />

• If you try to process documents that contain invalid characters or text that doesn't reflect the writing style<br />

of the person for whom the user was created, you may either damage the vocabulary by filling it with<br />

improper words or decrease recognition accuracy by building a Language Model from example that don't<br />

reflect the user's dictation style.<br />

<strong>Dragon</strong> Vocabulary Tool: Choosing Word Lists<br />

In this step you select word lists for the Vocabulary Tool to analyse. The Vocabulary Tool determines which words<br />

in the lists are not in the current vocabulary.<br />

A word list is an ASCII text document containing words or shorts phrases you want to add to the vocabulary. Each<br />

word or phrase should be on an individual line and may contain a spoken form separate from the written form by<br />

a backslash (\). For example, "& Co.\and Company".<br />

The following information and buttons appear on this screen:


Word Lists<br />

The names of files containing word lists that you can have the Vocabulary Tool analyse. The buttons to the right of<br />

this list allow you to add to and delete file names.<br />

Add Word List<br />

Click this button to open the Add Word List Files dialog box, which you can use to select file names to display in the<br />

documents list. You can hold down the CTRL key and click individual file names to select multiple files one at a time,<br />

or you can hold down the SHIFT key and click the first and last file names to select a range of files. Continue to click<br />

the Add Word List button and select different folders from which to add additional file names to the documents list.<br />

Remove Word List<br />

Click this button to remove selected file names from the documents list. You can hold down the CTRL key and click<br />

individual file names to select multiple documents one at a time, or you can hold down the SHIFT key and click the<br />

first and last file names to select a range of files.<br />

Notes<br />

57<br />

• Be careful to process word lists that contain only valid words or phrases. Otherwise you may fill the<br />

vocabulary with improper words or decrease recognition accuracy by building a Language Model from<br />

examples that don't reflect the user's normal dictation vocabulary.<br />

• You can create word list files from a current <strong>Dragon</strong> <strong>NaturallySpeaking</strong> user with the Export Words dialog<br />

box on the Tools menu of the <strong>Dragon</strong>Bar.<br />

<strong>Dragon</strong> Vocabulary Tool: Analyzing Settings<br />

In this step you specify how the <strong>Dragon</strong> Vocabulary Tool will analyze the documents and word list files you chose<br />

on the previous screen (Choose Documents or Choose Word Lists).<br />

You can change the following settings:<br />

Find unknown words<br />

Select this option to have the Vocabulary Tool find words that are not already in the vocabulary. Note: This option<br />

is only available if the Vocabulary Tool is analyzing documents and not word lists.<br />

Find known words with unknown capitalization<br />

Select this option to have the Vocabulary Tool find words that are already in the vocabulary but with a different<br />

capitalization.<br />

Preview the list of unknown words<br />

Select this option to have the Vocabulary Tool open the Preview New Words screen, which displays the unknown<br />

words and/or the known words with unique capitalization. You can use the Preview New Words to modify the list<br />

select specific words that the Vocabulary Tool found.<br />

Add all unknown words without previewing them


Select this option to have the Vocabulary Tool skip the Preview New Words screen. The Vocabulary Tool will add all<br />

the unknown words and/or the known words with unique capitalization to the vocabulary without the option of<br />

modifying the list.<br />

Note<br />

Use the Find known words with unknown capitalization option only with word lists that you are sure you want to<br />

add to the vocabulary. Otherwise you might add words to the vocabulary unintentionally.<br />

<strong>Dragon</strong> Vocabulary Tool: Analyzing Files<br />

In this the <strong>Dragon</strong> Vocabulary Tool analyses the documents and word list files you choose in the Choose<br />

Documents step or the Choose Word Lists step.<br />

This screen shows the following information and contains the following button:<br />

File list<br />

The file list is a scrolling list of the files or documents that the Vocabulary Tool is processing. A check mark next to<br />

the file name indicates that Vocabulary Tool has completed analyzing that file. An "X" mark indicates that the<br />

Vocabulary Tool has not successfully completed analyzing the file, either because the analysis was interrupted by<br />

the Stop button, or because an error occured while reading the contents of the file. An hourglass symbol appears<br />

next to the name of the file that Vocabulary Tool is currently analyzing.<br />

Stop/Resume<br />

Click Stop to end the analysis. Click Resume to restart the analysis.<br />

Progress bar<br />

The progress bar indicates how much of the current file has been analyzed.<br />

<strong>Dragon</strong> Vocabulary Tool: Previewing New Words<br />

In this step you can view the list of words that the Vocabulary Tool identified as either not being in the current<br />

vocabulary or as having a unique capitalization.<br />

The following information and buttons appear on this screen:<br />

Word<br />

You can scroll the Word list and use the check box to the left of the word to choose whether or not to add the word<br />

to the vocabulary. A check mark indicates that the word will be added. Removing the check mark indicates that the<br />

word will not be added.<br />

Frequency<br />

58


Frequency indicates how many times the word appears in the analyzed documents. This information appears only<br />

if you selected the "Add new words from documents and adapt to writing style" option on the Introduction screen<br />

of the wizard.<br />

Check All<br />

Click this button to check all the words in the Word list.<br />

Clear All<br />

Click this button to clear all the words in the Word list.<br />

Edit<br />

Click this button to open the Edit Word dialog box for a word you have selected. In this dialog box you can change<br />

both the written and enter a different spoken form of the selected word. The Edit Word dialog box also displays the<br />

context and frequency with which the word appears in the analyzed document.<br />

Save<br />

Click this button to open the Windows Save As dialog box so you can save the contents of the Word list as a file.<br />

Use the dialog box to specify a name and a location for this file. You can use this file with the Vocabulary Tool at a<br />

later time to modify the vocabulary of other users.<br />

Train added words<br />

Select this option to open the Train Added Words screen of the Vocabulary Tool where you can train selected words<br />

so that <strong>Dragon</strong> <strong>NaturallySpeaking</strong> can better recognize your pronunciation.<br />

The Train added words feature is available only when you run the <strong>Dragon</strong> Vocabulary Tool as part of a normal<br />

installation of <strong>Dragon</strong> <strong>NaturallySpeaking</strong>. You cannot train words using the Vocabulary Tool if you are running the<br />

<strong>Dragon</strong> DSS SDK version.<br />

<strong>Dragon</strong> Vocabulary Tool: Training Added Words<br />

In this step you can train <strong>Dragon</strong> <strong>NaturallySpeaking</strong> so that the program can better recognize your pronunciation.<br />

This feature is available only when you run the <strong>Dragon</strong> Vocabulary Tool as part of a normal installation of <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>. You cannot train words using the Vocabulary Tool if you are running the <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> SDK Server Edition (DSS) .<br />

The following information and buttons appear on this screen:<br />

Word<br />

The Word list contains the words you selected on the Preview New Words screen. Select the words you want to<br />

train from this list. A check mark in the box to the left of the word indicates that you want to train that word.<br />

Check All<br />

Click this button to select all the words in the Word list.<br />

59


Clear All<br />

Click this button to deselect all the words in the Word list.<br />

Train<br />

Click this button to open the Train dialog box where you can train <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to recognize your<br />

pronunciation of the words you selected. If you have selected more than one word to train, the Train dialog box<br />

shows them to you in the order that they appear in the list.<br />

Note<br />

Only the person who will be dictating with the user you are modifying can perform the training. If that person is<br />

unavailable for this Vocabulary Tool session, then training can also occur during a <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

session by clicking Train from the Words menu on the <strong>Dragon</strong>Bar.<br />

<strong>Dragon</strong> Vocabulary Tool: Language Model Building<br />

In this step you tell the Vocabulary Tool to build a new language model with the information that it has gathered<br />

in the preceding steps and specify the location and maximum size of the new vocabulary.<br />

You can specify the following settings:<br />

Build language model<br />

If this option is selected the Vocabulary Tool will build a new language model containing the words and other<br />

information it has gathered in preceding steps.<br />

Language Model locator<br />

If you are building a language model for a Solution Series version of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> you can select<br />

either the Middle or the User slot as a location. If you are building a language model for a Preferred version of<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> you can select only the User slot as a location.<br />

Language model size limit (Solution Series or SDK Server Edition only)<br />

If you build the Language Model into the Middle slot, you can also limit the size of the model. You can specify a limit<br />

between 0.5 megabytes to 5 megabytes. If you don't want to set a limit select Unspecified from the list.<br />

Existing Model built by:<br />

The version of the <strong>Dragon</strong> Vocabulary Builder that created the previous Language Model. This information only<br />

appears if the user you are building a language model for has an existing language model.<br />

Preserve existing model<br />

This option appears only if the user for which you are building a language model has an existing language model.<br />

Selecting Yes merges the new language model with the current one. Selecting No builds a new language model to<br />

replace the existing one. Normally, you should accept the recommended value, which varies by the language<br />

model location and the version of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> for which you are creating the language model. The<br />

recommendations for the Solution Series and Preferred editions are:<br />

60<br />

• For <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Solution Series, middle slot, the recommendation is No.


61<br />

• For <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Solution Series, user slot, the recommendation is Yes.<br />

• For <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Preferred, user slot, the recommendation is Yes.<br />

You cannot build a language model in the middle slot of <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Preferred.<br />

<strong>Dragon</strong> Vocabulary Tool: Summary Screen<br />

The Summary screen for the Vocabulary Tool displays information about the newly built language model.<br />

Details<br />

The details box contains following information:<br />

User<br />

The name of the user that Vocabulary Tool modified.<br />

Vocabulary<br />

The vocabulary type of the user.<br />

Language<br />

The language of the vocabulary, including any specific variation of that language, such as United States<br />

English or Southeast Asian English.<br />

Additional information<br />

The following information may also appear:<br />

o The names of the documents or word lists that were processed<br />

o The number of unknown words that were found<br />

o The number of added words<br />

o Whether or not the the Vocabulary Tool saved the previous language model or built a new<br />

language model, and if it did, which language model location was used.<br />

o Any warnings or any non-critical errors that might have occured during processing<br />

Save speech files<br />

Select this option to save the new speech file so that it is available for future <strong>Dragon</strong> <strong>NaturallySpeaking</strong> sessions.


Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> with Citrix<br />

Using <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix environment (overview)<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> includes support for deploying and running <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix<br />

environment.<br />

This section includes the following:<br />

62<br />

• Installing and publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

• Creating Policies for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

• Making Published Applications Work together<br />

• Setting Up the Program Neighborhood on Citrix clients<br />

• Starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from a Citrix client<br />

Sizing and performance information<br />

For sizing and performance information for running <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix environment, please see:<br />

http://www.nuance.com/naturallyspeaking/citrix<br />

Installing and publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> includes support for deploying and running <strong>Dragon</strong> <strong>NaturallySpeaking</strong> in a Citrix<br />

environment.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> can be run through the Citrix Webclient, Program Neighborhood Agent, and/or the<br />

Program Neighborhood.<br />

Requirements<br />

Server:<br />

Citrix Presentation Server 3.0 or 4.0<br />

Please check www.citrix.com to download the latest patches.<br />

Client:<br />

Citrix ICA clients 8.x or 9.x<br />

Installing and publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

1. Install <strong>Dragon</strong> <strong>NaturallySpeaking</strong> as you normally would other applications that you make available on the<br />

Citrix server, noting the installation directory.


63<br />

2. Publish <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

o If you installed <strong>Dragon</strong> <strong>NaturallySpeaking</strong>, you must publish it as an Application:<br />

When publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from the Presentation Server Console, use<br />

natspeak.exe as the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> executable. By default the <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> applications are installed to:<br />

\Program Files\Nuance\<strong>NaturallySpeaking</strong>9\Program<br />

For example:<br />

o If you installed the <strong>Dragon</strong> SDK Client Edition, you must publish the SDK as a Desktop from the<br />

Citrix Presentation Server Console in order to view and run the sample programs from a client.<br />

3. On the Specify Client Requirements dialog box, check the Enable legacy audio setting. For example, if you<br />

are using the Program Neighborhood:<br />

4. Publish the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Citrix Client Update as Content:


64<br />

When publishing the Citrix Client Update from the Presentation Server Console, use vddnspatch.exe as the<br />

Citrix Client Update executable. For example:<br />

Note: You must install this Client Update directly on each client computer. For more information, see<br />

Setting Up the Program Neighborhood on Citrix clients and Starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from a<br />

Citrix client.<br />

Create a list of applications on the Citrix Server<br />

For <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to work correctly with the other applications published on your Citrix servers, you<br />

must do the following:<br />

Creating Policies for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on the Citrix server<br />

You must create two policies for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> before users can access <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

from their desktops.<br />

Create the AudioIn policy<br />

1. From the Presentation Server Console, select Policies and click the Create Policy button (or<br />

Actions>Policy>Create Policy from the menu) to create a policy named AudioIn.<br />

2. 2. Select the AudioIn policy and then click the Properties button (or Actions>Properties) to set the<br />

properties. Use the Properties dialog to enable Microphones so the client’s microphones can be used for<br />

audio input. For example:<br />

3. Select the AudioIn policy and then click the Apply this policy to button (or Actions>Policy>Apply this<br />

policy…) to specify which users can use the AudioIn policy (in other words, all users who will use <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>). This displays the Policy Filters for the AudioIn Policy – select Users and grant access<br />

to the appropriate users.


Create the AudioOut policy<br />

65<br />

1. From the <strong>Management</strong> Console, select Policies and click the Create Policy… button (or<br />

Actions>Policy>Create Policy from the menu) to create a second policy named AudioOut.<br />

2. Select the AudioOut policy and then click the Properties button to set the properties to enable the Sound<br />

Quality and set the client audio quality to “High sound quality; lowest performance”. For example:<br />

3. Select the AudioOut policy and then click the Apply this policy to button (or Actions>Policy>Apply this<br />

policy…) to specify which users can use the AudioOut policy (in other words, all users who need access to<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong>). This displays the Policy Filters for the AudioOut Policy – select Users and grant<br />

access to the appropriate users.<br />

Making Published Applications Work together<br />

To be able to use a published <strong>Dragon</strong> <strong>NaturallySpeaking</strong> with another published application like Microsoft Word,<br />

both applications must be running in a single Citrix client session.<br />

Use the following guidelines to make sure all published applications work together.<br />

For the Administrator<br />

Give users access to applications<br />

There are two ways to give users access to applications:<br />

1. Publish the desktop and let users start applications from the published desktop.<br />

2. Publish all needed applications with identical settings. If the settings are not identical, <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> may not operate correctly in other published applications. For example, if Microsoft<br />

Word is published with different settings than the published <strong>NaturallySpeaking</strong>, the microphone hotkey will<br />

not work in Word.<br />

For the Client<br />

If you published separate applications and not a Desktop, use the following guidelines:


Notes<br />

66<br />

1. All applications must be started in Seamless mode.<br />

2. Don’t change Application Set settings when a published application is running.<br />

3. When using the Smooth Roaming feature with published applications on multiple computers, the user must<br />

either:<br />

o Close all published applications before moving to a new location.<br />

o Start the same published applications in the same order on all the machines that are used. If a user<br />

left a running published application on one machine and moved to another one, the user should<br />

start the same published application on the next machine. In this case, the user will connect to the<br />

already running application. For example, if the use left published Word running on one computer,<br />

moved to another computer, started published <strong>Dragon</strong> <strong>NaturallySpeaking</strong> and then Word,<br />

dictation in Word won't work because <strong>Dragon</strong> <strong>NaturallySpeaking</strong> is running in a new session. In<br />

this particular case, the user should first start Word and then <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

• Citrix starts two published applications in separate sessions for single user when:<br />

1. The applications are published with different settings (Colors, Enable Legacy Audio, Encryption).<br />

Citrix places applications into isolated Windows sessions if the color settings are different. Using<br />

different color settings may cause problems with dictation. If you have problems with applications<br />

with different color settings, use the same color settings for all applications.<br />

2. Any single application is published as a Desktop.<br />

3. The client does not start the application in Seamless mode.<br />

4. A client launches one application, changes Application Set settings, and then launches another<br />

application.<br />

5. A user starts different applications from different machines. If the user starts the same application<br />

from a different machine, it connects to the same session and disconnects the previous session, as<br />

in Smooth Roaming feature<br />

Setting Up the Program Neighborhood on Citrix clients<br />

After publishing <strong>Dragon</strong> <strong>NaturallySpeaking</strong> and the Citrix Client Update, the Citrix ICA clients should see both<br />

programs in their Citrix Program Neighborhood (or Web Client interface). For example:


Before starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> as a published application, you must enable sound on the client for the<br />

application set for <strong>Dragon</strong> <strong>NaturallySpeaking</strong> on each Citrix client.<br />

67<br />

1. From the Citrix Program Neighborhood, select the Application Set that contains <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

and the Citrix Client Update.<br />

2. From this Application Set click the Settings button .<br />

This displays the Settings dialog for the selected application set.<br />

3. Select the Default Options tab and unselect User server default and select Enable Sound. In the<br />

dropdown list select High Sound Quality. For example:<br />

Starting <strong>Dragon</strong> <strong>NaturallySpeaking</strong> from a Citrix client<br />

If you intend to dictate from the Citrix client, you must run the Citrix Client Update before you run <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> for the first time.<br />

Installing the Citrix Client Update<br />

4. Double-click the Citrix Client Update icon in the Program Neighborhood


68<br />

This starts the Citrix Client Update installer wizard.<br />

5. When prompted, click Next and then Patch. Clicking Patch starts the installation.<br />

6. Click Finish when the installation completes.<br />

After installing the Citrix Client Update, you can start <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to create your users.<br />

Notes<br />

• In order to run the Citrix Client Update, each client machine must be joined to the network domain of the<br />

Citrix server. In other words, the Citrix server must be able to recognize the client’s Windows logon<br />

credentials. If the client is not joined to network domain of the Citrix server, you will see the following error<br />

when trying to run the Citrix Client Update:<br />

If this is a problem, you can still use network resources by entering your domain user name and password.<br />

Before running the Citrix Client Update:<br />

1. From the Windows Explorer, click on the Tools menu and then click Map Network Drive.<br />

2. In Drive, type or select the drive letter to map to the shared resource.<br />

3. In Folder, type the server and optionally, the share name of the resource, in the form of \\server<br />

name\share name. You can also click Browse to locate the resource.<br />

4. Click Finish.<br />

5. In the User name and password dialog box, type your user name in the form of domain\user name.<br />

6. In Password, type your domain password.<br />

• If during the installation of Citrix Client Update you see the following error message:<br />

" Unable to set High Sound Quality in your Citrix client. It is recommended that you do this manually"


69<br />

Please double-check that the Audio settings on your client are set to high. For more information, see<br />

Setting up Citrix Clients.<br />

• If you are using a Phillips SpeechMike, set up your system so that sound playback is through a different<br />

device and not the SpeechMike. To do this, select Sound and Audio Devices from the Windows control<br />

panel and use the Audio tab to set your Sound playback and Sound recording devices.<br />

• There must be sound system installed on the client. For example, if your client has disabled USB audio, you<br />

cannot create a DNS user. If you disable USB audio, enable it and re-connect to the Citrix server.<br />

The Convert XML to DAT tool<br />

Using the Convert XML to DAT tool<br />

This tool (mycmdsxml2dat.exe) extracts user-defined <strong>NaturallySpeaking</strong> commands from a .XML file. The tool<br />

writes out the commands to a .DAT file. <strong>NaturallySpeaking</strong> uses .DAT files to store commands. To make these<br />

commands available to other <strong>NaturallySpeaking</strong> users, use the nsadmin tool or the Data Distribution Tool to<br />

copy the created .DAT files to those other users.<br />

Note: If you are using the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition, you can programmatically import<br />

<strong>NaturallySpeaking</strong> commands stored in .XML or .DAT files into a <strong>NaturallySpeaking</strong> user profile by using the<br />

DgnEngingControl::ImportMyCommands method.<br />

Starting Convert XML to DAT (mycmdsxml2dat.exe)<br />

To start Convert XML to DAT (mycmdsxml2dat.exe) select:<br />

� For <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

Start>All Programs><strong>Dragon</strong> <strong>NaturallySpeaking</strong> 9><strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

Tools>Convert XML to DAT<br />

� For <strong>Dragon</strong> <strong>NaturallySpeaking</strong> SDK Client Edition:<br />

Start>All Programs><strong>Dragon</strong> SDK Client Edition 9><strong>Dragon</strong> SDK Client Tools>Convert XML<br />

to DAT<br />

The Convert XML to DAT tool starts in a DOS window, listing the tool's syntax. To re-display the syntax, enter<br />

the following:<br />

>mycmdsxml2dat<br />

The mycmdsxml2dat.exe program is located in the \Program directory beneath the directory where DSC is<br />

installed. For example, in a default installation:<br />

C:\Program Files\Nuance\<strong>NaturallySpeaking</strong>9\Program>


Convert XML to DAT (mycmdsxml2dat.exe) syntax<br />

70<br />

Convert XML to DAT (mycmdsxml2dat.exe) uses the following syntax:<br />

mycmdsxml2dat.exe [options]<br />

Required parameters : Description<br />

The full path to the local copy of the current user's .DAT file<br />

The full path to the .XML file<br />

Optional parameters :<br />

-v Validates the specified .xml file over the Internet with a Nuance DTD (Document<br />

Type Definition) file. Disabled by default<br />

Using the XML to DAT tool<br />

To make a set of commands in an XML file available to other users:<br />

1. Create the XML file containing the commands to be used in <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

2. Execute the command line tool, mycmdsXML2DAT.exe, to convert the XML file .dat format.<br />

3. Use the nsadmin tool, to import the .dat file into <strong>Dragon</strong> <strong>NaturallySpeaking</strong> for all users.<br />

After using nsadmin or the Data Distribution Tool to copy the .DAT file to a user, that user will have the new<br />

commands available the next time they start <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

For more information, see:<br />

� Adding custom commands (nsadmin)<br />

� Adding and removing custom commands (Data Distribution Tool)<br />

Advanced Scripting Commands<br />

The MyCommands Editor: Advanced Scripting dialog box<br />

Use the MyCommands Editor: Advanced Scripting dialog box to create complex scripts and sequences to perform<br />

virtually any function on the computer using voice commands. Creating these commands requires familiarity with<br />

the Visual Basic programming language.<br />

MyCommand Name<br />

The name of the command. This is what you will say to execute the command. You can click the Train button to<br />

teach <strong>Dragon</strong> <strong>NaturallySpeaking</strong> how you pronounce this name. If you enter an angle bracket (


Description<br />

A short description of what the command does (optional).<br />

Group<br />

A list containing the categories in which you can place the command. You use these groups to locate the command<br />

in the Command Browser. By default, the groups <strong>Dragon</strong> and User-defined are available. To create your own group,<br />

select User-defined and type over it with a group name of your choosing.<br />

Availability<br />

Where the command will be available.<br />

71<br />

Global: The command will be available in every application.<br />

Application-specific: The command will be available in the application you specify. When you select this<br />

option, the applications currently open appear in a list. If the application you want is not open, use the<br />

Browse button to locate the application on your computer.<br />

Window-specific: The command will be available in the window you specify. When you select this option,<br />

the Application and Window lists appear. If the application or window you want is not in the list, you must<br />

close the MyCommands Editor: Advanced Scripting dialog box, open the application or window you want,<br />

and reopen the MyCommands Editor: Advanced Scripting dialog box to see the window listed.<br />

When you select either the Application-specific or Window-specific option, the Recognizable in states list appears.<br />

You can either select from the list or enter the name of a new state. A command with this option will be available<br />

in the state you specify within the window or application you specify.<br />

Command Type<br />

The command type, in this case, Advanced Scripting. There are three other types of commands:<br />

Text and Graphics commands<br />

Step-by-Step commands<br />

Macro Recorder commands<br />

Name Editor<br />

Click this button to open the MyCommands Name Editor dialog box. Use this dialog box to assign variables to your<br />

command such as a name for the command you want to create. Refer to the Help topic on the MyCommands Name<br />

Editor dialog box for more information.<br />

Script<br />

The Script editing window is the location where you create commands. Click the following buttons for an<br />

introduction to either the Advanced Scripting Basic Language or the <strong>Dragon</strong> Scripting Language.<br />

Advanced Scripting Basic Language<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Scripting Language Extensions<br />

Changes to a line of code are automatically capitalized and highlighted when a different line is selected. This<br />

autoformatting helps you catch typing errors.<br />

Break points can be toggled on/off. A dot at the front of the line indicates a break point.<br />

Toolbar<br />

The Script editing area contains tools to help you create, edit, and test scripts. Click the following button to read a<br />

description of these tools.<br />

The Scripting toolbar


Object:<br />

Select the object type from the list of available objects. The "(General)" object groups all of the procedures, which<br />

are not part of any specific object.<br />

Proc:<br />

The Proc list shows all the procedures for the current object. Use it to select the procedure type from the list of<br />

available procedures. A procedure that is not bold inserts the proper procedure definition for that procedure.<br />

Save<br />

Click Save to save the advanced scripting command. Note that you must give the command a name before this<br />

button is active.<br />

Cancel<br />

Click Cancel to close the Advanced Scripting dialog box without saving any changes you have made since you last<br />

clicked Save.<br />

Create New<br />

Click Create New to open the Advanced Scripting dialog box with a duplicate of the current command. You can<br />

rename and edit the command to create a new command.<br />

Note that this button is active only when you open the editor from the Script mode of the Command Browser by<br />

selecting a command and clicking Edit.<br />

Notes<br />

72<br />

If the Visual Basic code in an Advanced Scripting command contains some runtime errors, a message will<br />

appear describing the error and prompting you to correct it.<br />

Multiple Advanced Scripting commands cannot execute simultaneously. If one Advanced Scripting command<br />

is running, you cannot start another Advanced Scripting command until the first one is finished.<br />

Using ActiveX Components<br />

You can use ActiveX® components in your scripts. Use the following procedure to create commands with ActiveX<br />

components.<br />

To create commands with ActiveX Components<br />

On the Tools menu of the <strong>Dragon</strong>Bar, click Add New Command to open the MyCommands dialog box.<br />

By default, the MyCommands Text and Graphics dialog box opens. Select Advanced Scripting from the<br />

Command Type list to open the MyCommands Advanced Scripting dialog box.<br />

In the MyCommand name box, enter what you will say to start the command. Choose a phrase that is easy to<br />

remember but not likely to be used in normal dictation.<br />

In the Description box, enter a description that will help you identify the command.<br />

In the Group list, specify whether this command will be a <strong>Dragon</strong> command or a User-defined command. If it<br />

is User-defined, you can type over "User-defined" with a group name of your choosing. The new group<br />

name will appear in the list the next time you create a command.<br />

Specify whether the command will work everywhere (Global), in a specific application that you name, or in a<br />

specific window.


73<br />

Click the Browse Object tool to open the ActiveX Automation Members dialog box. Use this dialog box to<br />

build your script with ActiveX variables. If you would like more information about a specific variable, select<br />

it in the Methods/Properties box and click the question mark button to the left of the Help String box.<br />

When you are finished, close the ActiveX Automation Members dialog box and click Save on the MyCommands<br />

Advanced Scripting dialog box.<br />

The Script editing window<br />

You use the Script editing window in the MyCommands Editor: Advanced Scripting dialog box to edit and test your<br />

scripts.<br />

The Script editing window contains the following menu, windows, screens, tabs, and miscellaneous components.<br />

The Advanced Scripting menu<br />

The Script Editor toolbar<br />

The Object and Proc lists<br />

The Break Bar<br />

The Edit area<br />

The Status Bar<br />

The Object Browser<br />

The References dialog box<br />

The UserDialog Editor dialog box<br />

The Immediate, Watch, and Stack windows<br />

When you run a script, the Script editing window appears with three tabs below the toolbar. These are the<br />

Immediate, Watch, and Stack windows.


Item Description<br />

Immediate Evaluates expressions, assigns variables, or calls subroutines.<br />

Watch Displays the variables, expressions, and functions in the current script.<br />

Stack Displays the lines of code that called the current statement.<br />

These three tabs appear when you run your script.<br />

The Advanced Scripting menu<br />

You open the Advanced Scripting menu by pointing to the Script area of the MyCommands Advanced Scripting<br />

dialog box and right-clicking or by pressing Shift+F10. The menu has the following commands:<br />

Item Description<br />

Cut Moves the selected text to the Clipboard.<br />

Copy Copies the selected text to the Clipboard.<br />

Paste Pastes the Clipboard text over the selected text.<br />

Run Runs the script to completion. (If the macro is not active, start it.)<br />

Pause Stops the script. Execution can be resumed.<br />

End Terminates the script. Execution cannot be continued.<br />

Step Into Executes the current line. If the current line is a subroutine or function call, stop<br />

on the first line of that subroutine or function. (If the script is not active, start it.)<br />

Step to Cursor Executes until the line the cursor is on is the current line. (If the script is not<br />

active, start it.)<br />

Toggle Break Toggles a break point on the current line.<br />

74


Clear All Breaks Clears all break points.<br />

Quick Watch Shows the value of the expression under the insertion point in the immediate<br />

window.<br />

Browse Shows the methods of the expression under of the cursor. (see The Object<br />

Browser)<br />

Show Next<br />

Statement<br />

75<br />

Shows the next statement to be executed.<br />

References Opens the References dialog box, which shows the current script/module's<br />

references.<br />

The Advanced Scripting Editor toolbar<br />

The toolbar that appears in the Script editing window contains the following tools:<br />

Tool Description<br />

Cut Deletes the selected text.<br />

Copy Makes a copy of the selected text on the clipboard.<br />

Paste Inserts the contents of the clipboard at the insertion point.<br />

Undo Removes the previous action and restores the contents to their state before<br />

you performed the previous action.<br />

Redo Performs the previously undone action.<br />

Browse Object Opens the ActiveX Automation Members dialog box.<br />

Start/Resume Runs or resumes running the current script.<br />

Pause Stops execution of the current command at the current point in the script. You<br />

can restart the command at this point by clicking the Start/Resume icon.<br />

End Stops execution of the current command.<br />

Toggle Break Enables or disables a breakpoint at the current location.<br />

Evaluate Expression Displays the value of the currently selected variable.<br />

Shows Current<br />

Statement<br />

Displays the value of the currently selected statement.<br />

Step Into Moves program execution into the next statement or module to be run.<br />

Step Over Skips over the next statement or module to be run.<br />

Step Out Skips the remaining statements in the currently running script or subroutine<br />

and goes to the next subroutine or scripts.<br />

Edit UserDialog Displays the Edit UserDialog window where you can graphically create or<br />

modify a UserDialog.<br />

Edit Module<br />

Properties<br />

Disabled in this release of <strong>Dragon</strong> <strong>NaturallySpeaking</strong>.<br />

As a result of clicking the Step Into and Step Over buttons, the Immediate, Watch, and Stack windows may appear<br />

in the Script Editor. Click the following buttons to learn more about these windows.<br />

The Immediate Window


The Watch Window<br />

The Stack Window<br />

The Immediate window<br />

The Immediate window of the MyCommands Advanced Scripting dialog box allows you to evaluate an expression,<br />

assign a variable, or call a subroutine.<br />

76<br />

Type "?expr" to show the value of "expr".


77<br />

Type "var = expr" to change the value of "var".<br />

Type "Set var = expr" to change the reference of "var".<br />

Type "subname args" to call a subroutine or built-in instruction.<br />

Type "Trace" to toggle trace mode. Trace mode prints each statement in the Immediate window<br />

when a script is running.<br />

The Watch window<br />

The Watch window allows you to list the variables, functions, and expressions that are calculated and displayed,<br />

and see their current value.


You have to enter the name of a variable, function, or expression in the Watch window. Then, the Watch window<br />

will update the value of that variable, function, or expression.<br />

78<br />

The value of each line in the window is updated each time the execution pauses.


79<br />

You can change the expression to the left of arrow ( ).<br />

Press Enter to update all the values immediately.<br />

Press Ctrl-Y to delete the line.<br />

The Stack window<br />

The Stack window lists the lines that called the current statement.


80<br />

The first line is the current statement. The second line is the statement that called the first line, etc.<br />

Click on a line to bring that script into a sheet and highlight the line in the Script editing window.<br />

Object and Proc lists<br />

The Object list shows all the objects for the current module. The Proc list shows all the procedures for the current<br />

object.<br />

The "(General)" object groups all of the procedures, which are not part of any specific object.<br />

Selecting a procedure that is not bold inserts the proper procedure definition for that procedure.<br />

The Break bar<br />

The Break bar shows which lines have break points. It also shows which line is next to execute.


Click on the Break bar to toggle a break point for that line.<br />

The Edit area<br />

Use the Edit area to view or edit the current script.<br />

81<br />

You can only edit scripts that are not currently loaded.<br />

Changes to a line are automatically capitalized and highlighted when a different line is selected.<br />

Break points can be toggled on/off. A dot at the front of the line indicates a break point.


The Status bar<br />

The Status bar displays status information.<br />

In this example, the status is paused.<br />

The Object Browser<br />

The Object Browser shows information about all the special data types that are available.<br />

Click the Browse Object tool on the MyCommands Advanced Scripting dialog box toolbar to display the<br />

ActiveX Automation Members window.<br />

82


Item Description<br />

Library list Lists all the type libraries.<br />

DataType list Lists all the special data types.<br />

Methods/Properties<br />

list<br />

83<br />

Lists all the methods and/or properties for the current data type.<br />

Info area Displays the method/property name, result or value and the dispatch id. (A<br />

Methods/Properties item must be selected for this to be visible.)<br />

Help area Displays a description of the method or property. The question mark (?)<br />

button is enabled if the object's method/property has help file information.<br />

The "Help String" shows a short description of the method/property.<br />

Parameters list Lists all the parameters for the current method/property. (A<br />

Methods/Properties item must be selected for this to be visible.)<br />

Back button Returns to the previous path shown.<br />

Path edit box Displays the object browser's current path. (A Methods/Properties item must<br />

be selected for this to be visible.)<br />

Paste button Pastes the current method/property into the edit or immediate window.<br />

Close button Closes the object browser window.<br />

The References dialog box<br />

The References dialog box shows the current script or module's references. You can add or remove references to<br />

type libraries from the current script. You can also change the relative priority of a reference. Checked references<br />

are available to the current script. For example, if your script refers to Microsoft Word objects, the Word object


library must be checked. Each checked reference is searched in order from top to bottom. If the desired library<br />

does not appear in the Available References list, click Browse to locate it on your computer.<br />

To open the References dialog box, point to the Script area of the MyCommands Advanced Scripting dialog box and<br />

right-click or press Shift+F10. On the shortcut menu that appears, click References.<br />

Item Description<br />

Available<br />

References list<br />

84<br />

Lists all the registered type libraries. Check the box in front of a reference to<br />

add it. Uncheck the box to remove it.<br />

Priority Up button Moves the current reference towards the top of the list.<br />

Priority Down<br />

button<br />

Moves the current reference towards the bottom of the list.<br />

OK button Changes the current macro or module's references.<br />

Cancel button Closes the references dialog without changing the current macro or module's<br />

references.<br />

Browse button Opens a dialog box with which you can search for and select libraries. These<br />

are files with the extensions .OLB, .TLB, and .DLL.<br />

Info area Displays the selected reference's language and where it is located.<br />

The UserDialog Editor dialog box<br />

The UserDialog Editor dialog box allows you to create and modify dialog boxes.<br />

Click the Edit UserDialog tool on the MyCommands Advanced Scripting dialog box toolbar to display the<br />

UserDialog Editor dialog box.


In the code, a UserDialog is described by a Begin Dialog...End Dialog block. To graphically edit a UserDialog, place<br />

the current selection in a UserDialog block and click on the Edit UserDialog tool.<br />

The top row of icons in the UserDialog window has the following components, which you can use to edit the<br />

contents of a dialog box:<br />

Item Description<br />

Edit Item Properties Edits the selected item's properties. Hot key: Enter<br />

Delete Deletes the selected item. Hot key: Del<br />

Cut Moves the selected item to the Clipboard. Hot key: Ctrl+X<br />

Copy Copies the selected item to the Clipboard. Hot key: Ctrl+C<br />

Paste Pastes the Clipboard item in front of the selected item. Hot<br />

key: Ctrl+Z<br />

Move In Front (towards End<br />

Dialog)<br />

Move Behind (towards Begin<br />

Dialog)<br />

Select Behind (towards Begin<br />

Dialog)<br />

Select In Front (towards End<br />

Dialog)<br />

85<br />

Moves the selected item in front. Hot key: Ctrl+Up<br />

Moves the selected item behind). Hot key: Ctrl+Down<br />

Selects the item behind the selected item.<br />

Selects the item in front of the selected item.<br />

Set Grid Changes the grid settings. Hot key: Ctrl+G<br />

Save and Exit Saves the UserDialog and exits the UserDialog editor.<br />

The gallery on the left has the following options, listed from left to right and top to bottom. To add a control to your<br />

UserDialog, click this control's item in the gallery, then "draw" the control on the UserDialog grid.<br />

Item Description<br />

Select Selects, moves, or edits item mode.


Add GroupBox Adds a GroupBox item.<br />

Add Text Adds a Text item.<br />

Add TextBox Adds a TextBox item.<br />

Add CheckBox Adds a CheckBox item.<br />

Add OptionButton Adds an OptionButton item.<br />

Add ComboBox Adds a ComboBox item.<br />

Add ListBox Adds a ListBox item.<br />

Add DropListBox Adds a DropListBox item.<br />

Add Picture Adds a Picture item.<br />

Add OKButton Adds an OKButton item.<br />

Add CancelButton Adds a CancelButton item.<br />

Add PushButton Adds a PushButton item.<br />

Advanced Scripting Basic Language<br />

The Advanced Scripting Basic Language provides the core language definition. It is Visual Basic for Applications<br />

compatible.<br />

Language reference by group:<br />

86<br />

Declaration, Data Type, Assignment<br />

Flow Control, Error Handling<br />

Conversion, Variable Info<br />

Constant<br />

Math, String, Object, Time/Date<br />

File<br />

User Input, User Dialog, Dialog Function<br />

DDE<br />

Settings<br />

Miscellaneous<br />

Operator<br />

Objects Overview<br />

ActiveX Automation provides access to objects in other applications. Each object supports a particular set of<br />

methods and properties. Each method/property has zero or more parameters. Parameters may be optional, in<br />

which case the parameter can be specified by using name := value.<br />

objexpr.method [expr][, ...] [param := expr][,...]<br />

Call method for objexpr.


objexpr.method[([expr][, ...] [param := expr][,...])]<br />

Return the value of method for objexpr.<br />

objexpr.property[([expr][, ...] [param := expr][,...])]<br />

Return the value of property for objexpr.<br />

objexpr[([expr][, ...] [param := expr][,...])]<br />

Return the default value for the objexpr.<br />

objexpr.property[([expr][, ...])] = expr<br />

Assign the value of property for objexpr.<br />

objexpr[([expr][, ...])] = expr<br />

Assign the default value for the objexpr.<br />

Set objexpr.property[([expr][, ...])] = objexpr<br />

Set the object reference of property for objexpr.<br />

Note: objexpr!name is shorthand for objexpr.defaultproperty("name"). Use objexpr![name] if name contains any<br />

characters that are not allowed in an identifier.<br />

Operators<br />

Syntax<br />

^ Not * / \ Mod + - & < >= = Is And Or Xor Eqv Imp<br />

Description<br />

These operators are available for numbers n1 and n2 or strings s1 and s2. If any value in an expression is Null then<br />

the expression's value is Null. The order of operator evaluation is controlled by operator precedence.<br />

Operator Description<br />

- n1 Negate n1.<br />

n1 ^ n2 Raise n1 to the power of n2.<br />

n1 * n2 Multiply n1 by n2.<br />

n1 / n2 Divide n1 by n2.<br />

n1 \ n2 Divide the integer value of n1 by the integer value of n2.<br />

n1 Mod n2 Remainder of the integer value of n1 after dividing by the integer value of n2.<br />

n1 + n2 Add n1 to n2.<br />

s1 + s2 Concatenate s1 with s2.<br />

n1 - n2 Difference of n1 and n2.<br />

s1 & s2 Concatenate s1 with s2.<br />

n1 < n2 Return True if n1 is less than n2.<br />

n1 n2 Return True if n1 is greater than n2.<br />

n1 >= n2 Return True if n1 is greater than or equal to n2.<br />

n1 = n2 Return True if n1 is equal to n2.<br />

n1 n2 Return True if n1 is not equal to n2.<br />

s1 < s2 Return True if s1 is less than s2.<br />

s1 s2 Return True if s1 is greater than s2.<br />

s1 >= s2 Return True if s1 is greater than or equal to s2.<br />

s1 = s2 Return True if s1 is equal to s2.<br />

s1 s2 Return True if s1 is not equal to s2.<br />

Not n1 Bitwise invert the integer value of n1. Only Not True is False.<br />

n1 And n2 Bitwise and the integer value of n1 with the integer value n2.<br />

n1 Or n2 Bitwise or the integer value of n1 with the integer value n2.<br />

87


n1 Xor n2 Bitwise exclusive-or the integer value of n1 with the integer value n2.<br />

n1 Eqv n2 Bitwise equivalence the integer value of n1 with the integer value n2 (same as Not (n1<br />

Xor n2)).<br />

n1 Imp n2 Bitwise implicate the integer value of n1 with the integer value n2 (same as (Not n1)<br />

Or n2).<br />

Example<br />

Sub Main<br />

N1 = 10<br />

N2 = 3<br />

S1$ = "asdfg"<br />

S2$ = "hjkl"<br />

Debug.Print -N1 '-10<br />

Debug.Print N1 ^ N2 ' 1000<br />

Debug.Print Not N1 '-11<br />

Debug.Print N1 * N2 ' 30<br />

Debug.Print N1 / N2 ' 3.3333333333333<br />

Debug.Print N1 \ N2 ' 3<br />

Debug.Print N1 Mod N2 ' 1<br />

Debug.Print N1 + N2 ' 13<br />

Debug.Print S1$ + S2$ '"asdfghjkl"<br />

Debug.Print N1 - N2 ' 7<br />

Debug.Print N1 & N2 '"103"<br />

Debug.Print N1 < N2 'False<br />

Debug.Print N1 = N2 'True<br />

Debug.Print N1 = N2 'False<br />

Debug.Print N1 N2 'True<br />

Debug.Print S1$ < S2$ 'True<br />

Debug.Print S1$ = S2$ 'False<br />

Debug.Print S1$ = S2$ 'False<br />

Debug.Print S1$ S2$ 'True<br />

Debug.Print N1 And N2 ' 2<br />

Debug.Print N1 Or N2 ' 11<br />

Debug.Print N1 Xor N2 ' 9<br />

Debug.Print N1 Eqv N2 ' -10<br />

Debug.Print N1 Imp N2 ' -9<br />

End Sub<br />

All Functions by Groups<br />

Declaration:<br />

#Reference, #Uses, Attribute, Class Module, Code Module, Const, Declare, Deftype, Dim, Enum...End Enum,<br />

Function...End Function, Object Module, Option, Private, Property...End Property, Public, ReDim, Static, Sub...End<br />

Sub, Type...End Type. WithEvents<br />

Data Type:<br />

Any, Boolean, Byte, Currency, Date, Decimal, Double, Integer, Long, Object, PortInt, Single, String, String*n,<br />

Variant, obj type, user enum, user type.<br />

Assignment:<br />

Erase, Let, LSet, RSet, Set.<br />

88


Flow Control:<br />

Call, CallByName, Do...Loop, End, Exit, For...Next, For Each...Next, GoTo, If...ElseIf...Else...End If, MacroRun,<br />

MacroRunThis, Select Case...End Select, Stop, While...Wend.<br />

Error Handling:<br />

Err, Error, On Error, Resume.<br />

Conversion:<br />

Array, CBool, CByte, CCur, CDate, CDec, CDbl, CInt, CLng, CSng, CStr, CVar, CVDate, CVErr, Val.<br />

Variable Info:<br />

IsArray, IsDate, IsEmpty, IsError, IsMissing, IsNull, IsNumeric, IsObject, LBound, TypeName, UBound, VarType.<br />

Constant:<br />

Empty, False, Nothing, Null, True, Win16, Win32.<br />

Math:<br />

Abs, Atn, Cos, Exp, Fix, Int, Log, Randomize, Rnd, Round, Sgn, Sin, Sqr, Tan.<br />

String:<br />

Asc, AscB, AscW, Chr, ChrB, ChrW, Format, Hex, InStr, InStrB, InStrRev, LCase, Left, LeftB, Len, LenB, LTrim, Mid,<br />

MidB, Oct, Replace, Right, RightB, RTrim, Space, String, Str, StrComp, StrConv, StrReverse, Trim, UCase.<br />

Object:<br />

CreateObject, GetObject, Me, With...End With.<br />

Time/Date:<br />

Date, DateAdd, DateDiff, DatePart, DateSerial, DateValue, Day, Hour, Minute, Month, MonthName, Now, Second,<br />

Time, Timer, TimeSerial, TimeValue, Weekday, WeekdayName, Year.<br />

File:<br />

ChDir, ChDrive, Close, CurDir, Dir, EOF, FileAttr, FileCopy, FileDateTime, FileLen, FreeFile, Get, GetAttr, Input,<br />

Input, Kill, Line Input, Loc, Lock, LOF, MkDir, Name, Open, Print, Put, Reset, RmDir, Seek, Seek, SetAttr, Unlock,<br />

Write.<br />

User Input:<br />

Dialog, GetFilePath, InputBox, MsgBox. ShowPopupMenu<br />

User Dialog:<br />

Begin Dialog...End Dialog, CancelButton, CheckBox, ComboBox, DropListBox, GroupBox, ListBox, OKButton,<br />

OptionButton, OptionGroup, Picture, PushButton, Text, TextBox.<br />

Dialog Function:<br />

Dialog Func, DlgControlId, DlgCount, DlgEnable, DlgEnd, DlgFocus, DlgListBoxArray, DlgName, DlgNumber,<br />

DlgSetPicture, DlgText, DlgType, DlgValue, DlgVisible.<br />

DDE:<br />

DDEExecute, DDEInitiate, DDEPoke, DDERequest, DDETerminate, DDETerminateAll.<br />

Settings:<br />

DeleteSetting, GetAllSettings, GetSetting, SaveSetting<br />

Miscellaneous:<br />

AboutWinWrapBasic, AppActivate, Attribute, Beep, CallersLine, Choose, Clipboard, Command, Debug.Print,<br />

DoEvents, Environ, Eval, IIf, KeyName, MacroDir, QBColor, Rem, RGB, SendKeys, Shell, Wait.<br />

Operator:<br />

Operators: +, -, ^, *, /, \, Mod, +, -, &, =, , , =, Like. Not, And, Or, Xor, Eqv, Imp, Is.<br />

Assignment Group<br />

Erase, Let, LSet, RSet, Set.<br />

89


Constant Group<br />

Empty, False, Nothing, Null, True, Win16, Win32.<br />

Conversion Group<br />

Array, CBool, CByte, CCur, CDate, CDec, CDbl, CInt, CLng, CSng, CStr, CVar, CVDate, CVErr, Val.<br />

Data Type Group<br />

Any, Boolean, Byte, Currency, Date, Decimal, Double, Integer, Long, Object, PortInt, Single, String, String*n,<br />

Variant, obj type, user enum, user type.<br />

DDE Group<br />

DDEExecute, DDEInitiate, DDEPoke, DDERequest, DDETerminate, DDETerminateAll.<br />

Declaration Group<br />

#Reference, #Uses, Attribute, Class Module, Code Module, Const, Declare, Deftype, Dim, Enum...End Enum,<br />

Function...End Function, Object Module, Option, Private, Property...End Property, Public, ReDim, Static, Sub...End<br />

Sub, Type...End Type. WithEvents<br />

Dialog Function Group<br />

Dialog Func, DlgControlId, DlgCount, DlgEnable, DlgEnd, DlgFocus, DlgListBoxArray, DlgName, DlgNumber,<br />

DlgSetPicture, DlgText, DlgType, DlgValue, DlgVisible.<br />

Error Handling Group<br />

Err, Error, On Error, Resume.<br />

90


File Group<br />

ChDir, ChDrive, Close, CurDir, Dir, EOF, FileAttr, FileCopy, FileDateTime, FileLen, FreeFile, Get, GetAttr, Input,<br />

Input, Kill, Line Input, Loc, Lock, LOF, MkDir, Name, Open, Print, Put, Reset, RmDir, Seek, Seek, SetAttr, Unlock,<br />

Write.<br />

Flow Control Group<br />

Call, CallByName, Do...Loop, End, Exit, For...Next, For Each...Next, GoTo, If...ElseIf...Else...End If, MacroRun,<br />

MacroRunThis, Select Case...End Select, Stop, While...Wend.<br />

Math Group<br />

Abs, Atn, Cos, Exp, Fix, Int, Log, Randomize, Rnd, Round, Sgn, Sin, Sqr, Tan.<br />

Miscellaneous Group<br />

AboutWinWrapBasic, AppActivate, Attribute, Beep, CallersLine, Choose, Clipboard, Command, Debug.Print,<br />

DoEvents, Environ, Eval, IIf, KeyName, MacroDir, QBColor, Rem, RGB, SendKeys, Shell, Wait.<br />

Object Group<br />

CreateObject, GetObject, Me, With...End With.<br />

Operator Group<br />

Operators: +, -, ^, *, /, \, Mod, +, -, &, =, , , =, Like. Not, And, Or, Xor, Eqv, Imp, Is.<br />

Settings Group<br />

DeleteSetting, GetAllSettings, GetSetting, SaveSetting<br />

91


String Group<br />

Asc, AscB, AscW, Chr, ChrB, ChrW, Format, Hex, InStr, InStrB, InStrRev, LCase, Left, LeftB, Len, LenB, LTrim, Mid,<br />

MidB, Oct, Replace, Right, RightB, RTrim, Space, String, Str, StrComp, StrConv, StrReverse, Trim, UCase.<br />

Time/Date Group<br />

Date, DateAdd, DateDiff, DatePart, DateSerial, DateValue, Day, Hour, Minute, Month, MonthName, Now, Second,<br />

Time, Timer, TimeSerial, TimeValue, Weekday, WeekdayName, Year.<br />

User Dialog Group<br />

Begin Dialog...End Dialog, CancelButton, CheckBox, ComboBox, DropListBox, GroupBox, ListBox, MultiListBox,<br />

OKButton, OptionButton, OptionGroup, Picture, PushButton, Text, TextBox.<br />

User Input Group<br />

Dialog, GetFilePath, InputBox, MsgBox. ShowPopupMenu<br />

Variable Info Group<br />

IsArray, IsDate, IsEmpty, IsError, IsMissing, IsNull, IsNumeric, IsObject, LBound, TypeName, UBound, VarType.<br />

Class Module<br />

Group<br />

Declaration<br />

Description<br />

A class module implements an ActiveX Automation object.<br />

Has a set of Public procedures accessible from other macros and modules.<br />

These public symbols are accessed via an object variable.<br />

Public Consts, Types, arrays, fixed length strings are not allowed.<br />

A class module is similar to a object module except that no instance is automatically created.<br />

To create an instance use:<br />

92


93<br />

C:\ABCTemp\vbs\Dim_Definition00000109.htm<br />

Dim Obj As classname<br />

Set Obj = New classname<br />

Can optionally contain Attributes one of which must be VB_Name.<br />

See Also: Attribute Definition/Statement, Code Module, Object Module, Uses.<br />

Example<br />

'MyCommands macro<br />

'#Uses "File.CLS"<br />

Sub Main<br />

Dim File As New File<br />

File.Attach "C:\AUTOEXEC.BAT"<br />

Debug.Print File.ReadLine<br />

End Sub<br />

'File.CLS class file<br />

VERSION 1.0 CLASS<br />

BEGIN<br />

MultiUse = -1 'True<br />

END<br />

Attribute VB_Name = "File"<br />

Option Explicit<br />

Dim FN As Integer<br />

Public Sub Attach(FileName As String)<br />

FN = FreeFile<br />

Open FileName For Input As #FN<br />

End Sub<br />

Public Sub Detach()<br />

If FN 0 Then Close #FN<br />

FN = 0<br />

End Sub<br />

Public Function ReadLine() As String<br />

Line Input #FN,ReadLine<br />

End Function<br />

Private Sub Class_Initialize()<br />

Debug.Print "Class_Initialize"<br />

End Sub<br />

Private Sub Class_Terminate()<br />

Debug.Print "Class_Terminate"<br />

Detach<br />

End Sub


Code Module<br />

Group<br />

Declaration<br />

Description<br />

A Code module implements a code library.<br />

Has a set of Public procedures accessible from other macros and modules.<br />

The public symbols are accessed directly.<br />

Can optionally contain Attributes<br />

See Also: Attribute Definition/Statement, Class Module, Object Module, Uses.<br />

Example<br />

'MyCommands macro<br />

'#Uses "Module1.BAS"<br />

Sub Main<br />

Debug.Print Value '"Hello"<br />

End Sub<br />

'Module1.BAS code file<br />

Attribute VB_Name = "Module1"<br />

Option Explicit<br />

Private mValue As String<br />

Property Get Value() As String<br />

Value = mValue<br />

End Property<br />

'this sub is called when the module is first loaded<br />

Private Sub Main<br />

mValue = "Hello"<br />

End Sub<br />

Object Module<br />

Group<br />

Declaration<br />

Description<br />

An object module implements an ActiveX Automation object.<br />

It has a set of Public procedures accessible from other macros and modules.<br />

These public symbols are accessed via the name of the object module or an object variable.<br />

94


Public Consts, Types, arrays, fixed length strings are not allowed.<br />

An object module is similar to a class module except that one instance is automatically created. That instance<br />

has the same name as the object module's name.<br />

To create additional instances use:<br />

C:\ABCTemp\vbs\Dim_Definition00000109.htm<br />

Dim Obj As objectname<br />

Set Obj = New objectname<br />

It can optionally contain Attributes one of which must be VB_Name.<br />

See Also: Attribute Definition/Statement, Class Module, Code Module, Uses.<br />

Example<br />

'MyCommands macro<br />

'#Uses "Sample.OBM"<br />

Sub Main<br />

Debug.Print Sample.Name<br />

End Sub<br />

'Sample.OBM object file<br />

VERSION 1.0 OBJECT<br />

BEGIN<br />

MultiUse = -1 'True<br />

END<br />

Attribute VB_Name = "Sample"<br />

Option Explicit<br />

Public Function Name() As String<br />

Name = "Sample Object Module"<br />

End Function<br />

Any Data Type<br />

Group<br />

Data Type<br />

Description<br />

Any variable expression (Declare only).<br />

Boolean Data Type<br />

Group<br />

Data Type<br />

95


Description<br />

A True or False value.<br />

Byte Data Type<br />

Group<br />

Data Type<br />

Description<br />

An 8 bit unsigned integer value.<br />

Currency Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 64 bit fixed point real. (A twos complement binary value scaled by 10000.)<br />

Date Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 64 bit real value. The whole part represents the date, while the fractional part is the time of day. (December 30,<br />

1899 = 0.) Use #date# as a literal date value in an expression.<br />

Decimal Data Type<br />

Group<br />

Data Type<br />

Description<br />

96


Win32 only. A 96 bit scaled real value. Decimal is not a valid variable type, but Variant variables can contain<br />

decimal values (see CDec). A decimal number is of the form: s*m*10^-p where<br />

s - sign (+1 or -1)<br />

m - mantissa, unsigned binary value of 96 bits (0 to 79,228,162,514,264,337,593,543,950,335)<br />

p - scaling power (0 to +28)<br />

Double Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 64 bit real value.<br />

Integer Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 16 bit integer value.<br />

Long Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 32 bit integer value.<br />

Object Data Type<br />

Group<br />

Data Type<br />

97


Description<br />

An object reference value. (see Objects)<br />

PortInt Data Type<br />

Group<br />

Data Type<br />

Description<br />

A portable integer value.<br />

For Win16: A 16 bit integer value.<br />

For Win32: A 32 bit integer value.<br />

Single Data Type<br />

Group<br />

Data Type<br />

Description<br />

A 32 bit real value.<br />

String Data Type<br />

Group<br />

Data Type<br />

Description<br />

An arbitrary length string value. Some useful string constants are predefined:<br />

vbNullChar - same as Chr(0)<br />

vbCrLf - same as Chr(13) & Chr(10)<br />

vbCr - same as Chr(13)<br />

vbLf - same as Chr(10)<br />

vbBack - same as Chr(8)<br />

vbFormFeed - same as Chr(12)<br />

vbTab - same as Chr(9)<br />

98


vbVerticalTab - same as Chr(11)<br />

String*n Data Type<br />

Group<br />

Data Type<br />

Description<br />

A fixed length (n) string value.<br />

UserDialog Data Type<br />

Group<br />

Data Type<br />

Description<br />

A usertype defined by Begin Dialog UserDialog.<br />

Variant Data Type<br />

Group<br />

Data Type<br />

Description<br />

An empty, numeric, currency, date, string, object, error code, null or array value.<br />

Usertype definition<br />

User defined types are defined with Type.<br />

Empty Keyword<br />

Group<br />

99


Constant<br />

Description<br />

A variantvar that does not have any value.<br />

False Keyword<br />

Group<br />

Constant<br />

Description<br />

A condexpr is false when its value is zero. A function that returns False returns the value 0.<br />

Nothing Keyword<br />

Group<br />

Constant<br />

Description<br />

An objexpr that does not refer to any object.<br />

Null Keyword<br />

Group<br />

Constant<br />

Description<br />

A variant expression that is null. A null value propagates through an expression causing the entire expression to be<br />

Null. Attempting to use a Null value as a string or numeric argument causes a run-time error. A Null value prints<br />

as "#NULL#".<br />

Example<br />

Sub Main<br />

X = Null<br />

Debug.Print X = Null '#NULL#<br />

Debug.Print IsNull(X) 'True<br />

End Sub<br />

100


True Keyword<br />

Group<br />

Constant<br />

Description<br />

A conditional expression is True when its value is non-zero. A function that returns True returns the value -1.<br />

Win16 Keyword<br />

Group<br />

Constant<br />

Description<br />

True if running in 16 bits. False if running in 32 bits.<br />

Win32 Keyword<br />

Group<br />

Constant<br />

Description<br />

True if running in 32 bits. False if running in 16 bits.<br />

Friend Keyword<br />

Group<br />

Declaration<br />

Description<br />

Friend Functions, Propertys and Subs in a module are available in all other macros/modules that access it. Friends<br />

are not accessible via Object variables.<br />

101


Main Sub<br />

Syntax<br />

Sub Main()<br />

...<br />

End Sub<br />

-or-<br />

Private Sub Main()<br />

...<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

Form 1: Each macro must define Sub Main. A macro is a "program". Running a macro starts the Sub Main and<br />

continues to execute until the subroutine finishes.<br />

Form 2: A code module may define a Private Sub Main. This Sub Main is the code module initialization subroutine.<br />

If Main is not defined then no special initialization occurs.<br />

See Also: Code Module.<br />

Object_Initialize Sub<br />

Syntax<br />

Private Sub Object_Initialize()<br />

...<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

Object module initialization subroutine. Each time a new instance is created for a Object module the<br />

Object_Initialize sub is called. If Object_Initialize is not defined then no special initialization occurs.<br />

Note: Object_Initialize is also called for the instance that is automatically created.<br />

See Also: Object Module, Object_Terminate.<br />

Object_Terminate Sub<br />

Syntax<br />

102


Private Sub Object_Terminate()<br />

...<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

Object module termination subroutine. Each time an instance is destroyed for a Object module the<br />

Object_Terminate sub is called. If Object_Terminate is not defined then no special termination occurs.<br />

See Also: Object Module, Object_Initialize.<br />

Set Instruction<br />

Syntax<br />

Set objvar = objexpr<br />

-or-<br />

Set objvar = New objtype<br />

Group<br />

Assignment<br />

Description<br />

Form 1: Set objvar's object reference to the object reference of objexpr.<br />

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

The Set instruction is how object references are assigned.<br />

Example<br />

Sub Main<br />

Dim App As Object<br />

Set App = CreateObject("WinWrap.CppDemoApplication")<br />

App.Move 20,30 ' move icon to 20,30<br />

Set App = Nothing<br />

App.Quit ' run-time error (no object)<br />

End Sub<br />

Private Keyword<br />

Group<br />

Declaration<br />

Description:<br />

103


Private Consts, Declares, Functions, Propertys, Subs and Types are only available in the current macro/module.<br />

Public Keyword<br />

Group<br />

Declaration<br />

Description<br />

Public Consts, Declares, Functions, Propertys, Subs and Types in a module are available in all other<br />

macros/modules that access it.<br />

AboutWinWrapBasic Instruction<br />

Syntax<br />

AboutWinWrapBasic [Timeout]<br />

Group<br />

Miscellaneous<br />

Description<br />

Show the WinWrap Basic about box.<br />

Parameter Description<br />

Timeout This numeric value is the maximum number of seconds to show the about box. A<br />

value less than or equal to zero displays the about box until the user closes it. If this<br />

value is omitted then a three second timeout is used.<br />

Example<br />

Sub Main<br />

AboutWinWrapBasic<br />

End Sub<br />

Abs Function<br />

Syntax<br />

Abs(Num)<br />

Group<br />

Math<br />

104


Description<br />

Return the absolute value.<br />

Parameter Description<br />

Num Return the absolute value of this numeric value. If this value is Null then Null is<br />

returned.<br />

Example<br />

Sub Main<br />

Debug.Print Abs(9) ' 9<br />

Debug.Print Abs(0) ' 0<br />

Debug.Print Abs(-9) ' 9<br />

End Sub<br />

AppActivate Instruction<br />

Syntax<br />

AppActivate Title$<br />

-or-<br />

AppActivate TaskID<br />

Group<br />

Miscellaneous<br />

Description<br />

Form 1: Activate the application top-level window titled Title$. If no window by that title exists then the first<br />

window with at title that starts with Title$ is activated. If no window matches then an error occurs.<br />

Form 2: Activate the application top-level window for task TaskID. If no window for that task exists then an error<br />

occurs.<br />

Parameter Description<br />

Title$ The name shown in the title bar of the window.<br />

TaskID This numeric value is the task identifier.<br />

See Also: SendKeys, Shell( ).<br />

Example<br />

Sub Main<br />

' make ProgMan the active application<br />

AppActivate "Program Manager"<br />

End Sub<br />

arglist definition<br />

[ | expr | param:=expr ][, ...]<br />

A list of zero or more exprs that are assigned to the parameters of the procedure.<br />

105


106<br />

A positional parameter may be skipped by omitting the expression. Only optional parameters may be<br />

skipped.<br />

Positional parameter assignment is done with expr. Each parameter is assigned in turn. By name parameter<br />

assignment may follow.<br />

By name parameter assignment is done with param:=expr. All following parameters must be assigned by<br />

name.<br />

Array Function<br />

Syntax<br />

Array([expr[, ...]])<br />

Group<br />

Conversion<br />

Description<br />

Return a variant value array containing the exprs.<br />

Example<br />

Sub Main<br />

X = Array(0,1,4,9)<br />

Debug.Print X(2) ' 4<br />

End Sub<br />

Array variable definition<br />

A variable that holds an array of values. A Variant variable can hold an array. Dynamic arrays can be<br />

ReDimensioned.<br />

As [New] type definition<br />

Dim, Private, Public and Static statements may declare variable types using As type or As New objtype. A variable<br />

declared using As New objtype is automatically created prior to use, if the variable is Nothing.<br />

Asc Function<br />

Syntax<br />

Asc(S$)


Group<br />

String<br />

Description<br />

Return the ASCII value.<br />

Note: A similar function, AscB, returns the first byte in S$. Another similar function, AscW, returns the Unicode<br />

number.<br />

Parameter Description<br />

S$ Return the ASCII value of the first char in this string value.<br />

See Also: Chr$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Asc("A") ' 65<br />

End Sub<br />

As type definition<br />

Variable and parameter types, as well as, function and property results may be specified using As type: Boolean,<br />

Byte, Currency, Date, Double, Integer, Long, Object, PortInt, Single, String, String*n, UserDialog, Variant, objtype,<br />

userenum, usertype.<br />

Atn Function<br />

Syntax<br />

Atn(Num)<br />

Group<br />

Math<br />

Description<br />

Return the arc tangent.<br />

Parameter Description<br />

Num Return the arc tangent of this numeric value. This is the number of radians. There are<br />

2*Pi radians in a full circle.<br />

Example<br />

Sub Main<br />

Debug.Print Atn(1)*4 ' 3.1415926535898<br />

End Sub<br />

107


Attribute definition<br />

A file attribute is zero or more of the following values added together.<br />

Attribute Value<br />

vbNormal 0 Normal file.<br />

vbReadOnly 1 Read-only file.<br />

vbHidden 2 Hidden file.<br />

vb<strong>System</strong> 4 <strong>System</strong> file.<br />

vbVolume 8 Volume label.<br />

vbDirectory 16 MS-DOS directory.<br />

vbArchive 32 File has changes since last backup.<br />

Attribute Definition/Statement<br />

Syntax<br />

Attribute attributename = value<br />

Attribute varname.attributename = value<br />

Attribute procname.attributename = value<br />

Group<br />

Declaration<br />

Description<br />

All attribute definitions and statements are ignored except for:<br />

108<br />

Form 1: Module level attribute<br />

Attribute VB_Name = "name"<br />

Attribute VB_GlobalNameSpace = bool<br />

Attribute VB_Creatable = bool<br />

Attribute VB_PredeclaredId = bool<br />

Attribute VB_Exposed = bool<br />

Attribute VB_HelpID = int<br />

Attribute VB_Description = "text"<br />

VB_Name - Declares the name of the class module or object module.<br />

VB_GlobalNameSpace - Declares the class module as a global class. (ignored)<br />

VB_Creatable - Declares the module as creatable (True), non-creatable (False). (ignored)<br />

VB_PredeclaredId - Declares the module as a predeclared identifier (True). (ignored)<br />

VB_Exposed - Declares the module as public (True). (ignored)<br />

VB_HelpID - Declares the module's help context displayed by the object browser.<br />

VB_Description - Declares the module's help text displayed by the object browser.<br />

Form 2: Macro/Module level variable attribute<br />

Public varname As Type<br />

Attribute varname.VB_VarUserMemId = 0<br />

Attribute varname.VB_VarHelpID = int<br />

Attribute varname.VB_VarDescription = "text"


109<br />

VB_VarUserMemID - Declares Public varname as the default property for a class module or object module.<br />

VB_VarHelpID - Declares the variable's help context displayed by the object browser.<br />

VB_VarDescription - Declares the variable's help text displayed by the object browser.<br />

Form 3: User defined procedure attribute<br />

[Sub | Function | Property [Get|Let|Set] procname ...<br />

Attribute procname.VB_UserMemId = 0<br />

Attribute procname.VB_HelpID = int<br />

Attribute procname.VB_Description = "text"<br />

...<br />

End [Sub | Function | Property]<br />

VB_UserMemID - Declares Property procname as the default property for a class module or object module.<br />

VB_HelpID - Declares the procedure's help context displayed by the object browser.<br />

VB_Description - Declares the procedure's help text displayed by the object browser.<br />

HelpFile:<br />

Each macro/module can define the HelpFile for the object browser:<br />

'#HelpFile "helpfile"<br />

where "helpfile" is a full path to the help file associated with the help text and help context.<br />

Beep Instruction<br />

Syntax<br />

Beep<br />

Group<br />

Miscellaneous<br />

Description<br />

Sound the bell.<br />

Example<br />

Sub Main<br />

Beep ' beep the bell<br />

End Sub<br />

Begin Dialog Definition<br />

Syntax<br />

Begin Dialog UserDialog [X, Y,] DX, DY[, Title$] _<br />

[, .dialogfunc]<br />

User Dialog Item


[User Dialog Item]...<br />

End Dialog<br />

Group<br />

User Dialog<br />

Description<br />

Define a UserDialog type to be used later in a Dim As UserDialog statement.<br />

Parameter Description<br />

X This numeric value is the distance from the left edge of the screen to the left edge of<br />

the dialog box. It is measured in 1/8ths of the average character width for the<br />

dialog's font. If this is omitted then the dialog will be centered.<br />

Y This numeric value is the distance from the top edge of the screen to the top edge of<br />

the dialog box. It is measured in 1/12ths of the average character width for the<br />

dialog's font. If this is omitted then the dialog will be centered.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ This string value is the title of the user dialog. If this is omitted then there is no title.<br />

dialogfunc This is the function name that implements the DialogFunc for this UserDialog. If this<br />

is omitted then the UserDialog doesn't have a dialogfunc.<br />

User Dialog Item<br />

One of: CancelButton, CheckBox, ComboBox, DropListBox, GroupBox, ListBox, MultiListBox, OKButton,<br />

OptionButton, OptionGroup, PushButton, Text, TextBox.<br />

See Also: Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

Big-endian definition<br />

Multiple byte data values (not strings) are stored with the highest order byte first. For example, the long integer<br />

&H01020304 is stored as this sequence of four bytes: &H01, &H02, &H03 and &H04. A Binary or Random file<br />

written using Put uses little-endian format so that it can be read using Get on any machine. (Big-endian machines,<br />

like the Power-PC, reverse the bytes as they are read by Get or written by Put.)<br />

See Also: Dir( ), GetAttr( ), SetAttr( ).<br />

110


Call Instruction<br />

Syntax<br />

Call name[(arglist)]<br />

-or-<br />

name [arglist]<br />

Group<br />

Flow Control<br />

Description<br />

Evaluate the arglist and call subroutine (or function) name with those values. Sub (or function) name must be<br />

previously defined by either a Sub, Function or Property definition. If name is a function then the result is discarded.<br />

If Call is omitted then name must be a subroutine and the arglist is not enclosed in parens.<br />

See Also: Declare, Sub.<br />

Example<br />

Sub Show(Title$,Value)<br />

Debug.Print Title$;"=";Value<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Call Show("2000/9",2000/9) ' 222.2222222222<br />

Show "1


vbSet 8 Set the property's reference<br />

Example<br />

Sub Main<br />

On Error Resume Next<br />

CallByName Err, "Raise", vbMethod, 1<br />

Debug.Print CallByName(Err, "Number", vbGet) ' 1<br />

End Sub<br />

CallersLine Function<br />

Syntax<br />

CallersLine[(Depth)]<br />

Group<br />

Miscellaneous<br />

Description<br />

Return the caller's line as a text string.<br />

The text format is: "[macroname|subname#linenum] linetext".<br />

Parameter Description<br />

Depth This integer value indicates how deep into the stack to get the caller's line. If Depth<br />

= -1 then return the current line. If Depth = 0 then return the calling subroutine's<br />

current line, etc.. If Depth is greater than or equal to the call stack depth then a null<br />

string is returned. If this value is omitted then the depth is 0.<br />

Example<br />

Sub Main<br />

A<br />

End Sub<br />

Sub A<br />

Debug.Print CallersLine '"[(untitled 1)|Main# 2] A"<br />

End Sub<br />

CancelButton Dialog Item Definition<br />

Syntax<br />

CancelButton X, Y, DX, DY[, .Field]<br />

Group<br />

User Dialog<br />

Description<br />

112


Define a cancel button item. Pressing the Cancel button from a Dialog instruction causes a run-time error.<br />

(Dialog( ) function call returns 0.)<br />

Parameter Description<br />

X This numeric value is the distance from the left edge of the screen to the left edge of<br />

the dialog box. It is measured in 1/8ths of the average character width for the<br />

dialog's font.<br />

Y This numeric value is the distance from the top edge of the screen to the top edge of<br />

the dialog box. It is measured in 1/12ths of the average character width for the<br />

dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this is omitted then the field name is "Cancel".<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,30,"Please push the Cancel button"<br />

OKButton 40,90,40,20<br />

CancelButton 110,90,60,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for cancel)<br />

Debug.Print "Cancel was not pressed"<br />

End Sub<br />

CBool Function<br />

Syntax<br />

CBool(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a boolean value. Zero converts to False, while all other values convert to True.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a boolean value.<br />

Example<br />

Sub Main<br />

Debug.Print CBool(-1) 'True<br />

Debug.Print CBool(0) 'False<br />

Debug.Print CBool(1) 'True<br />

End Sub<br />

113


CByte Function<br />

Syntax<br />

CByte(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a byte value.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a byte value.<br />

Example<br />

Sub Main<br />

Debug.Print CByte(1.6) ' 2<br />

End Sub<br />

CCur Function<br />

Syntax<br />

CCur(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a currency value.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a currency value.<br />

Example<br />

Sub Main<br />

Debug.Print CCur("1E6") ' 1000000<br />

End Sub<br />

CDate Function<br />

Syntax<br />

114


CDate(Num|$)<br />

-or-<br />

CVDate(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a date value.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a date value.<br />

Example<br />

Sub Main<br />

Debug.Print CDate(2) ' 1/1/00<br />

End Sub<br />

CDbl Function<br />

Syntax<br />

CDbl(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a double precision real.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a double precision real.<br />

Example<br />

Sub Main<br />

Debug.Print CDbl("1E6") ' 1000000<br />

End Sub<br />

CDec Function<br />

Syntax<br />

CDec(Num|$)<br />

Group<br />

Conversion<br />

115


Description<br />

Win32 only. Convert to a decimal (96 bit scaled real).<br />

Parameter Description<br />

Num|$ Convert a number or string value to a 96 bit scaled real.<br />

Example<br />

Sub Main<br />

Debug.Print CDec("1E16")+0.1 ' 10000000000000000.1<br />

End Sub<br />

charlist definition<br />

A group of one or more characters enclosed by [ ] as part of Like operator's right string expression.<br />

This list contains single characters and/or character ranges which describe the characters in the list.<br />

A range of characters is indicated with a hyphen (-) between two characters. The first character must be<br />

ordinally less than or equal to the second character.<br />

Special pattern characters like ?, *, # and [ can be matched as literal characters.<br />

The ] character can not be part of charlist, but it can be part of the pattern outside the charlist.<br />

ChDir Instruction<br />

Syntax<br />

ChDir Dir$<br />

Group<br />

File<br />

Description<br />

Change the current directory to Dir$.<br />

Parameter Description<br />

Dir$ This string value is the path and name of the directory.<br />

See Also: ChDrive, CurDir$( ).<br />

Example<br />

Sub Main<br />

ChDir "C:\"<br />

Debug.Print CurDir$() '"C:\"<br />

End Sub<br />

116


ChDrive Instruction<br />

Syntax<br />

ChDrive Drive$<br />

Group<br />

File<br />

Description<br />

Change the current drive to Drive$.<br />

Parameter Description<br />

Drive$ This string value is the drive letter.<br />

See Also: ChDir, CurDir$( ).<br />

Example<br />

Sub Main<br />

ChDrive "B"<br />

Debug.Print CurDir$() '"B:\"<br />

End Sub<br />

CheckBox Dialog Item Definition<br />

Syntax<br />

CheckBox X, Y, DX, DY, Title$, .Field[, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a checkbox item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Field The value of the check box is accessed via this field. Unchecked is 0, checked is 1 and<br />

grayed is 2.<br />

Options This numeric value controls the type of check box. Choose one value from following<br />

table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 Check box is either checked or unchecked.<br />

117


1 Check box is either checked, unchecked or grayed, and it switches between checked and<br />

unchecked when clicked.<br />

2 Check box is either checked, unchecked or grayed, and it cycles through all three states<br />

as the button is clicked.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

CheckBox 10,25,180,15,"&Check box",.Check<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.Check = 1<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.Check<br />

End Sub<br />

Choose Function<br />

Syntax<br />

Choose(Index, expr[, ...])<br />

Group<br />

Flow Control<br />

Description<br />

Return the value of the expr indicated by Index.<br />

Parameter Description<br />

Index The numeric value indicates which expr to return. If this value is less than one<br />

or greater than the number of exprs then Null is returned.<br />

expr<br />

All expressions are evaluated.<br />

See Also: If, Select Case, IIf( ).<br />

Example<br />

Sub Main<br />

Debug.Print Choose(2,"Hi","there") '"there"<br />

End Sub<br />

118


Chr$ Function<br />

Syntax<br />

Chr[$](Num)<br />

Group<br />

String<br />

Description<br />

Return a one char string for the ASCII value.<br />

Note: A similar function, ChrB, returns a single byte ASCII string. Another similar function, ChrW, returns a single<br />

char Unicode string.<br />

Parameter Description<br />

Num Return one char string for this ASCII numeric value.<br />

See Also: Asc( ).<br />

Example<br />

Sub Main<br />

Debug.Print Chr$(48) '"0"<br />

End Sub<br />

Chr$ Function<br />

Syntax<br />

Chr[$](Num)<br />

Group<br />

String<br />

Description<br />

Return a one char string for the ASCII value.<br />

Note: A similar function, ChrB, returns a single byte ASCII string. Another similar function, ChrW, returns a single<br />

char Unicode string.<br />

Parameter Description<br />

Num Return one char string for this ASCII numeric value.<br />

See Also: Asc( ).<br />

Example<br />

Sub Main<br />

Debug.Print Chr$(48) '"0"<br />

End Sub<br />

119


Chr$ Function<br />

Syntax<br />

Chr[$](Num)<br />

Group<br />

String<br />

Description<br />

Return a one char string for the ASCII value.<br />

Note: A similar function, ChrB, returns a single byte ASCII string. Another similar function, ChrW, returns a single<br />

char Unicode string.<br />

Parameter Description<br />

Num Return one char string for this ASCII numeric value.<br />

See Also: Asc( ).<br />

Example<br />

Sub Main<br />

Debug.Print Chr$(48) '"0"<br />

End Sub<br />

CInt Function<br />

Syntax<br />

CInt(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a 16 bit integer. If Num|$ is too big (or too small) to fit then an overflow error occurs.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a 16 bit integer.<br />

Example<br />

Sub Main<br />

Debug.Print CInt(1.6) ' 2<br />

End Sub<br />

120


Class_Initialize Sub<br />

Syntax<br />

Private Sub Class_Initialize()<br />

...<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

Class module initialization subroutine. Each time a new instance is created for a class module, the Class_Initialize<br />

sub is called. If Class_Initialize is not defined, then no special initialization occurs.<br />

See Also: Code Module, Class_Terminate.<br />

Class_Terminate Sub<br />

Syntax<br />

Private Sub Class_Terminate()<br />

...<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

Class module termination subroutine. Each time an instance is destroyed for a class module the Class_Terminate<br />

sub is called. If Class_Terminate is not defined then no special termination occurs.<br />

See Also: Code Module, Class_Initialize.<br />

Class Module<br />

Group<br />

Declaration<br />

Description<br />

A class module implements an ActiveX Automation object.<br />

Has a set of Public procedures accessible from other macros and modules.<br />

These public symbols are accessed via an object variable.<br />

121


Public Consts, Types, arrays, fixed length strings are not allowed.<br />

A class module is similar to a object module except that no instance is automatically created.<br />

To create an instance use:<br />

C:\ABCTemp\vbs\Dim_Definition00000109.htm<br />

Dim Obj As classname<br />

Set Obj = New classname<br />

Can optionally contain Attributes one of which must be VB_Name.<br />

See Also: Attribute Definition/Statement, Code Module, Object Module, Uses.<br />

Example<br />

'MyCommands macro<br />

'#Uses "File.CLS"<br />

Sub Main<br />

Dim File As New File<br />

File.Attach "C:\AUTOEXEC.BAT"<br />

Debug.Print File.ReadLine<br />

End Sub<br />

'File.CLS class file<br />

VERSION 1.0 CLASS<br />

BEGIN<br />

MultiUse = -1 'True<br />

END<br />

Attribute VB_Name = "File"<br />

Option Explicit<br />

Dim FN As Integer<br />

Public Sub Attach(FileName As String)<br />

FN = FreeFile<br />

Open FileName For Input As #FN<br />

End Sub<br />

Public Sub Detach()<br />

If FN 0 Then Close #FN<br />

FN = 0<br />

End Sub<br />

Public Function ReadLine() As String<br />

Line Input #FN,ReadLine<br />

End Function<br />

Private Sub Class_Initialize()<br />

Debug.Print "Class_Initialize"<br />

End Sub<br />

Private Sub Class_Terminate()<br />

Debug.Print "Class_Terminate"<br />

Detach<br />

End Sub<br />

122


Clipboard Instruction/Function<br />

Syntax<br />

Clipboard Text$<br />

-or-<br />

Clipboard[$][( )]<br />

Group<br />

Miscellaneous<br />

Description<br />

Form 1: Set the clipboard to Text$. This is similar to the Edit|Copy menu command.<br />

Form 2: Return the text in the clipboard.<br />

Parameter Description<br />

Text$ Put this string value into the clipboard.<br />

Example<br />

Sub Main<br />

Debug.Print Clipboard$()<br />

Clipboard "Hello"<br />

Debug.Print Clipboard$() '"Hello"<br />

End Sub<br />

CLng Function<br />

Syntax<br />

CLng(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a 32 bit long integer. If Num|$ is too big (or too small) to fit then an overflow error occurs.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a 32 bit integer.<br />

Example<br />

Sub Main<br />

Debug.Print CLng(1.6) ' 2<br />

End Sub<br />

123


Close Instruction<br />

Syntax<br />

Close [[#]StreamNum][, ...]<br />

Group<br />

File<br />

Description<br />

Close StreamNums.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros. If this is omitted then all open streams for the current<br />

macro/module are closed.<br />

See Also: Open, Reset.<br />

Example<br />

Sub Main<br />

' read the first line of XXX and print it<br />

Open "XXX" For Input As #1<br />

Line Input #1,L$<br />

Debug.Print L$<br />

Close #1<br />

End Sub<br />

ComboBox Dialog Item Definition<br />

Syntax<br />

ComboBox X, Y, DX, DY, StrArray$( ), .Field$[, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a combobox item. Combo boxes combine the functionality of an edit box and a list box.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

124


StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the non-null<br />

elements of the array are used.<br />

Field$ The value of the combo box is accessed via this field. This is the text in the edit box.<br />

Options This numeric value controls the type of combo box. Choose one value from following<br />

table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 List is not sorted.<br />

2 List is sorted.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Dim combos$(3)<br />

combos$(0) = "Combo 0"<br />

combos$(1) = "Combo 1"<br />

combos$(2) = "Combo 2"<br />

combos$(3) = "Combo 3"<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

ComboBox 10,25,180,60,combos$(),.combo$<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.combo$ = "none"<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.combo$<br />

End Sub<br />

Command$ Function<br />

Syntax<br />

Command[$]<br />

Group<br />

Miscellaneous<br />

Description<br />

Contains the value of the MacroRun parameters.<br />

See Also: MacroRun.<br />

Example<br />

Sub Main<br />

Debug.Print "Command line parameter is: """;<br />

Debug.Print Command$;<br />

Debug.Print """"<br />

End Sub<br />

125


condexpr definition<br />

An expression that returns a numeric result. If the result is zero then the conditional is False. If the result is<br />

non-zero then the conditional is True.<br />

0 'false<br />

-1 'true<br />

X > 20 'true if X is greater than 20<br />

S$ = "hello" 'true if S$ equals "hello"<br />

Const Definition<br />

Syntax<br />

[ | Private | Public ] _<br />

Const name[type] [As Type] = expr[, ...]<br />

Group<br />

Declaration<br />

Description<br />

Define name as the value of expr. The expr can refer to other constants or built-in functions. If the type of the<br />

constants is not specified, the type of expr is used. Constants defined outside a Sub, Function or Property block are<br />

available in the entire macro/module.<br />

C:\ABCTemp\vbs\Private_Keyword.htm<br />

Private is assumed if neither Private or Public is specified.<br />

Note: Const statement in a Sub, Function or Property block may not use Private or Public.<br />

Example<br />

Sub Main<br />

Const Pi = 4*Atn(1), e = Exp(1)<br />

Debug.Print Pi ' 3.14159265358979<br />

Debug.Print e ' 2.71828182845905<br />

End Sub<br />

Cos Function<br />

Syntax<br />

Cos(Num)<br />

Group<br />

Math<br />

126


Description<br />

Return the cosine.<br />

Parameter Description<br />

Num Return the cosine of this numeric value. This is the number of radians. There are 2*Pi<br />

radians in a full circle.<br />

Example<br />

Sub Main<br />

Debug.Print Cos(1) ' 0.54030230586814<br />

End Sub<br />

CreateObject Function<br />

Syntax<br />

CreateObject(Class$)<br />

Group<br />

Object<br />

Description<br />

Create a new object of type Class$. Use Set to assign the returned object to an object variable.<br />

Parameter Description<br />

Class$ This string value is the application's registered class name. If this application is not<br />

currently active it will be started.<br />

See Also: Objects.<br />

Example<br />

Sub Main<br />

Dim App As Object<br />

Set App = CreateObject("WinWrap.CppDemoApplication")<br />

App.Move 20,30 ' move icon to 20,30<br />

Set App = Nothing<br />

App.Quit ' run-time error (no object)<br />

End Sub<br />

CSng Function<br />

Syntax<br />

CSng(Num|$)<br />

Group<br />

Conversion<br />

127


Description<br />

Convert to a single precision real. If Num|$ is too big (or too small) to fit then an overflow error occurs.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a single precision real.<br />

Example<br />

Sub Main<br />

Debug.Print CSng(Sqr(2)) ' 1.4142135381699<br />

End Sub<br />

CStr Function<br />

Syntax<br />

CStr(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a string.<br />

Parameter Description<br />

Num|$ Convert a number or string value to a string value.<br />

Example<br />

Sub Main<br />

Debug.Print CStr(Sqr(2)) '"1.4142135623731"<br />

End Sub<br />

CurDir$ Function<br />

Syntax<br />

CurDir[$]([Drive$])<br />

Group<br />

File<br />

Description<br />

Return the current directory for Drive$.<br />

Parameter Description<br />

Drive$ This string value is the drive letter. If this is omitted or null then return the current<br />

directory for the current drive.<br />

128


See Also: ChDir, ChDrive.<br />

Example<br />

Sub Main<br />

Debug.Print CurDir$()<br />

End Sub<br />

CVar Function<br />

Syntax<br />

CVar(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a variant value.<br />

Parameter Description<br />

Num|$ Convert a number or string value (or object reference) to a variant value.<br />

Example<br />

Sub Main<br />

Debug.Print CVar(Sqr(2)) ' 1.4142135623731<br />

End Sub<br />

CVErr Function<br />

Syntax<br />

CVErr(Num|$)<br />

Group<br />

Conversion<br />

Description<br />

Convert to a variant that contains an error code. An error code can't be used in expressions.<br />

Parameter Description<br />

Num|$ Convert a number or string value to an error code.<br />

See Also: IsError.<br />

Example<br />

Sub Main<br />

129


Debug.Print CVErr(1) ' Error 1<br />

End Sub<br />

Date Function<br />

Syntax<br />

Date[$]<br />

Group<br />

Time/Date<br />

Description<br />

Return today's date as a date value.<br />

See Also: Now, Time, Timer.<br />

Example<br />

Sub Main<br />

Debug.Print Date ' example: 1/1/1995<br />

End Sub<br />

DateAdd Function<br />

Syntax<br />

DateAdd(interval, number, dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return a date value a number of intervals from another date.<br />

Parameter Description<br />

interval This string value indicates which kind of interval to add.<br />

number Add this many intervals. Use a negative value to get an earlier date.<br />

dateexpr Calculate the new date relative to this date value. If this value is Null then Null is<br />

returned.<br />

Interval Description<br />

yyyy Year<br />

q Quarter<br />

m Month<br />

y Day of year<br />

d Day<br />

w Weekday<br />

130


ww Week<br />

h Hour<br />

n Minute<br />

s Second<br />

See Also: DateDiff, DatePart.<br />

Example<br />

Sub Main<br />

Debug.Print DateAdd("yyyy",1,#1/1/2000#) '1/1/2001<br />

End Sub<br />

DateDiff Function<br />

Syntax<br />

DateDiff(interval, dateexpr1, dateexpr2)<br />

Group<br />

Time/Date<br />

Description<br />

Return the number of intervals between two dates.<br />

Parameter Description<br />

interval This string value indicates which kind of interval to subtract.<br />

dateexpr1 Calculate the from this date value to dateexpr2. If this value is Null then Null is<br />

returned.<br />

dateexpr2 Calculate the from dateexpr1 to this date value. If this value is Null then Null is<br />

returned.<br />

Interval Description<br />

yyyy Year<br />

q Quarter<br />

m Month<br />

y Day of year<br />

d Day<br />

w Weekday<br />

ww Week<br />

h Hour<br />

n Minute<br />

s Second<br />

See Also: DateAdd, DatePart.<br />

Example<br />

Sub Main<br />

Debug.Print DateDiff("yyyy",#1/1/1990#,#1/1/2000#) ' 10<br />

End Sub<br />

131


dateexpr definition<br />

An expression that returns a date result. Use #literal-date# to express a date value.<br />

#1/1/2000# ' Jan 1, 2000<br />

Now+7 ' seven days from now<br />

DateSerial(Year(Now)+1,Month(Now),Day(Now))<br />

' one year from now<br />

DatePart Function<br />

Syntax<br />

DatePart(interval, dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the number from the date corresponding to the interval.<br />

Parameter Description<br />

interval This string value indicates which kind of interval to extract.<br />

dateexpr Get the interval from this date value. If this value is Null then Null is returned.<br />

Parameter Description<br />

yyyy Year (100-9999) Quarter (1-4)<br />

m Month (1-12)<br />

y Day of year (1-366)<br />

d Day (1-31)<br />

w Weekday (1-7)<br />

ww Week (1-53)<br />

h Hour (0-23)<br />

n Minute (0-59)<br />

s Second (0-59)<br />

See Also: DateAdd, DateDiff.<br />

Example<br />

Sub Main<br />

Debug.Print DatePart("yyyy",#1/1/2000#) ' 2000<br />

End Sub<br />

DateSerial Function<br />

Syntax<br />

DateSerial(Year, Month, Day)<br />

132


Group<br />

Time/Date<br />

Description<br />

Return a date value.<br />

Parameter Description<br />

Year This numeric value is the year (0 to 9999). (0 to 99 are interpreted by the operating<br />

system.)<br />

Month This numeric value is the month (1 to 12).<br />

Day This numeric value is the day (1 to 31).<br />

See Also: DateValue, TimeSerial, TimeValue.<br />

Example<br />

Sub Main<br />

Debug.Print DateSerial(2000,7,4) '7/4/2000<br />

End Sub<br />

DateValue Function<br />

Syntax<br />

DateValue(Date$)<br />

Group<br />

Time/Date<br />

Description<br />

Return the day part of the date encoded as a string.<br />

Parameter Description<br />

Date$ Convert this string value to the day part of date it represents.<br />

See Also: DateSerial, TimeSerial, TimeValue.<br />

Example<br />

Sub Main<br />

Debug.Print DateValue("1/1/2000 12:00:01 AM")<br />

'1/1/2000<br />

End Sub<br />

Day Function<br />

Syntax<br />

Day(dateexpr)<br />

133


Group<br />

Time/Date<br />

Description<br />

Return the day of the month (1 to 31).<br />

Parameter Description<br />

dateexpr Return the day of the month for this date value. If this value is Null then Null is<br />

returned.<br />

See Also: Date( ), Month( ), Weekday( ), Year( ).<br />

Example<br />

Sub Main<br />

Debug.Print Day(#1/1/1900#) ' 1<br />

Debug.Print Day(#1/2/1900#) ' 2<br />

End Sub<br />

DDEExecute Instruction<br />

Syntax<br />

DDEExecute ChanNum, Command$[, Timeout]<br />

Group<br />

DDE<br />

Description<br />

Send the DDE Execute Command$ string via DDE ChanNum.<br />

Parameter Description<br />

ChanNum This is the channel number returned by the DDEInitiate function. Up to 10 channels<br />

may be used at one time.<br />

Command$ Send this command value to the server application. The interpretation of this value is<br />

defined by the server application.<br />

Timeout The command will generate an error if the number of seconds specified by the<br />

timeout is exceeded before the command has completed. The default is five seconds.<br />

Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

DDEExecute ChanNum,"[CreateGroup(XXX)]"<br />

DDETerminate ChanNum<br />

End Sub<br />

134


DDEInitiate Function<br />

Syntax<br />

DDEInitiate(App$, Topic$)<br />

Group<br />

DDE<br />

Description<br />

Initiate a DDE conversation with App$ using Topic$. If the conversation is successfully started then the return<br />

value is a channel number that can be used with other DDE instructions and functions.<br />

Parameter Description<br />

App$ Locate this server application.<br />

Topic$ This is the server application's topic. The interpretation of this value is defined by the<br />

server application.<br />

Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

DDEExecute ChanNum,"[CreateGroup(XXX)]"<br />

DDETerminate ChanNum<br />

End Sub<br />

DDEPoke Instruction<br />

Syntax<br />

DDEPoke ChanNum, Item$, Data$[, Timeout]<br />

Group<br />

DDE<br />

Description<br />

Poke Data$ to the Item$ via DDE ChanNum.<br />

Parameter Description<br />

ChanNum This is the channel number returned by the DDEInitiate function. Up to 10 channels<br />

may be used at one time.<br />

Item$ This is the server application's item. The interpretation of this value is defined by the<br />

server application.<br />

Data$ Send this data value to the server application. The interpretation of this value is<br />

defined by the server application.<br />

Timeout The command will generate an error if the number of seconds specified by the<br />

timeout is exceeded before the command has completed. The default is five seconds.<br />

Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

135


DDEPoke ChanNum,"Group","XXX"<br />

DDETerminate ChanNum<br />

End Sub<br />

DDERequest$ Function<br />

Syntax<br />

DDERequest[$](ChanNum, Item$[, Timeout])<br />

Group<br />

DDE<br />

Description<br />

Request information for Item$. If the request is not satisfied then the return value will be a null string.<br />

Parameter Description<br />

ChanNum This is the channel number returned by the DDEInitiate function. Up to 10 channels<br />

may be used at one time.<br />

Item$ This is the server application's item. The interpretation of this value is defined by the<br />

server application.<br />

Timeout The command will generate an error if the number of seconds specified by the<br />

timeout is exceeded before the command has completed. The default is five seconds.<br />

Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

Debug.Print DDERequest$(ChanNum,"Groups")<br />

DDETerminate ChanNum<br />

End Sub<br />

DDETerminate Instruction<br />

Syntax<br />

DDETerminate ChanNum<br />

Group<br />

DDE<br />

Description<br />

Terminate DDE ChanNum.<br />

Parameter Description<br />

ChanNum This is the channel number returned by the DDEInitiate function. Up to 10 channels<br />

may be used at one time.<br />

136


Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

DDEExecute ChanNum,"[CreateGroup(XXX)]"<br />

DDETerminate ChanNum<br />

End Sub<br />

DDETerminateAll Instruction<br />

Syntax<br />

DDETerminateAll<br />

Group<br />

DDE<br />

Description<br />

Terminate all open DDE channels.<br />

Example<br />

Sub Main<br />

ChanNum = DDEInitiate("PROGMAN","PROGMAN")<br />

DDEExecute ChanNum,"[CreateGroup(XXX)]"<br />

DDETerminateAll<br />

End Sub<br />

Debug Object<br />

Syntax<br />

Debug.Clear<br />

-or-<br />

Debug.Print [expr[; ...][;]]<br />

Group<br />

Miscellaneous<br />

Description<br />

Form 1: Clear the output window.<br />

Form 2: Print the expr(s) to the output window. Use semi-colons (;) to separate expressions. A num is<br />

automatically converted to a string before printing (just like Str$( )). If the instruction does not end with a<br />

semicolon, then a new line is printed at the end.<br />

Example<br />

137


Sub Main<br />

X = 4<br />

Debug.Print "X/2=";X/2 ' 2<br />

Debug.Print "Start..."; ' don't print a new line<br />

Debug.Print "Finish" ' print a new line<br />

End Sub<br />

Declare Definition<br />

Syntax<br />

[ | Private | Public ] _<br />

Declare Sub name Lib "dll name" _<br />

[Alias "module name"] [([param[, ...]])]<br />

-or-<br />

[ | Private | Public ] _<br />

Declare Function name[type] Lib "dll name" _<br />

[Alias "module name"] [([param[, ...]])] [As type[()]]<br />

Group<br />

Declaration<br />

Description<br />

Interface to a DLL defined subroutine or function. The values of the calling arglist are assigned to the params.<br />

Declare defaults to Public if neither Private or Public is specified.<br />

WARNING! Be very careful when declaring DLL subroutines or functions. If you make a mistake and declare the<br />

parameters or result incorrectly then Windows might halt. Save any open documents before testing new DLL<br />

declarations.<br />

C:\ABCTemp\vbs\Err_Object.htm<br />

Err.LastDLLError returns the error code for that last DLL call (Windows 32 bit versions only).<br />

Parameter Description<br />

name This is the name of the subroutine or function being defined. If Alias "module name"<br />

is omitted then this is the module name, too.<br />

"dll name" This is the DLL file where the module's code is.<br />

params A list of zero or more params that are used by the DLL subroutine or function. (Note:<br />

"module<br />

name"<br />

138<br />

A ByVal string's value may be modified by the DLL.)<br />

This is the name of the module in the DLL file. If this is #number then it is the ordinal<br />

number of the module. If it is omitted then name is the module name.<br />

The DLL is searched for the specified module name. If this module exists, it is used.<br />

All As String parameters are converted from Unicode to ASCII prior to calling the<br />

DLL and from ASCII to Unicode afterwards. (Use "Unicode:module name" to prevent<br />

ASCII to Unicode conversion.)<br />

If the module does not exist, one or two other module names are tried:<br />

1) For Windows NT only: The module name with a "W" appended is tried. All As<br />

String parameters are passed as Unicode to calling the DLL.<br />

2) For Windows NT only: The module name with an "A" appended is tried. All As<br />

String parameters are converted from Unicode to ASCII prior to calling the DLL and<br />

from ASCII to Unicode afterwards.<br />

If none of these module names is found a run-time error occurs.<br />

See Also: Function, Sub, Call.


Example<br />

Declare Function GetForegroundWindow& Lib "user32" ()<br />

Declare Function GetWindowTextLengthA& Lib "user32"(ByVal hwnd&)<br />

Declare Sub GetWindowTextA Lib "user32"(ByVal hwnd&, ByVal lpsz$, ByVal cbMax&)<br />

Function ActiveWindowTitle$()<br />

ActiveWindowTitle$ = vbCr<br />

ActiveWindow = GetForegroundWindow()<br />

TitleLen = GetWindowTextLengthA(ActiveWindow)<br />

If TitleLen > 0 Then<br />

TitleLen = TitleLen + 1<br />

Title$ = Space$(TitleLen)<br />

GetWindowTextA ActiveWindow,Title$,TitleLen<br />

ActiveWindowTitle$ = Title$<br />

End If<br />

End Function<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Clipboard ActiveWindowTitle$<br />

End Sub<br />

Def Definition<br />

Syntax<br />

Def{Bool|Cur|Date|Dbl|Int|Lng|Obj|Sng|Str|Var} _<br />

letterrange[, ...]<br />

Group<br />

Declaration<br />

Description<br />

Define untyped variables as:<br />

DefBool - Boolean<br />

DefByte - Byte<br />

DefCur - Currency<br />

DefDate - Date<br />

DefDbl - Double<br />

DefInt - Integer<br />

DefLng - Long<br />

DefObj - Object<br />

DefSng - Single<br />

DefStr - String<br />

DefVar - Variant<br />

Parameter Description<br />

letterrange letter, or A letter is one of A to Z. When letter-letter is used, the first letter must be<br />

139


letter-letter alphabetically before the second letter. Variable names that begin with a<br />

letter in this range default to declared type.<br />

See Also: Option.<br />

Example<br />

140<br />

If a variable name begins with a letter not specific in any letterrange then the<br />

variable is a Variant. The letterranges are not allowed to overlap.<br />

DefInt A,C-W,Y' integer<br />

DefBool B ' boolean<br />

DefStr X ' string<br />

' all others are variant<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

B = 1 ' B is an boolean<br />

Debug.Print B ' True<br />

X = "A" ' X is a string<br />

Debug.Print X '"A"<br />

Z = 1 ' Z is a variant (anything)<br />

Debug.Print Z ' 1<br />

Z = "Z"<br />

Debug.Print Z '"Z"<br />

End Sub<br />

DeleteSetting Instruction<br />

Syntax<br />

DeleteSetting AppName$, Section$[, Key$]<br />

Group<br />

Settings<br />

Description<br />

Delete the settings for Key in Section in project AppName. Win16 and Win32s store settings in a .ini file named<br />

AppName. Win32 stores settings in the registration database.<br />

Parameter Description<br />

AppName$ This string value is the name of the project which has this Section and Key.<br />

Section$ This string value is the name of the section of the project settings.<br />

Key$ This string value is the name of the key in the section of the project settings. If this<br />

is omitted then delete the entire section.<br />

Example<br />

Sub Main<br />

SaveSetting "MyApp","Font","Size",10<br />

DeleteSetting "MyApp","Font","Size"<br />

End Sub


dialogfunc definition<br />

A dialog function executes while a UserDialog is visible.<br />

DialogFunc Prototype<br />

Syntax<br />

Function dialogfunc(DlgItem$, Action%, SuppValue%) _<br />

As Boolean<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

...<br />

Case 2 ' Value changing or button pressed<br />

...<br />

Case 3 ' TextBox or ComboBox text changed<br />

...<br />

Case 4 ' Focus changed<br />

...<br />

Case 5 ' Idle<br />

...<br />

Case 6 ' Function key<br />

...<br />

End Select<br />

End Function<br />

Group<br />

Dialog Function<br />

Description<br />

A dialogfunc implements the dynamic dialog capabilities.<br />

Parameter Description<br />

DlgItem This string value is the name of the user dialog item's field.<br />

Action This numeric value indicates what action the dialog function is being asked to do.<br />

SuppValue This numeric value provides additional information for some actions.<br />

Action/Description<br />

141<br />

Dialog box initialization. DlgItem is a null string. SuppValue is the dialog's window handle. Set dialogfunc =<br />

True to terminate the dialog.<br />

CheckBox, DropListBox, ListBox, MultiListBox, or OptionGroup: DlgItem's value has changed. SuppValue is<br />

the new value.<br />

CancelButton, OKButton or PushButton: DlgItem's button was pushed. SuppValue is meaningless. Set<br />

dialogfunc = True to prevent the dialog from closing.<br />

ComboBox or TextBox: DlgItem's text changed and losing focus. SuppValue is the number of characters.<br />

Item DlgItem is gaining focus. SuppValue is the item that is losing focus. (The first item is 0, second is 1,<br />

etc.)<br />

Idle processing. DlgItem is a null string. SuppValue is zero. Set dialogfunc = True to continue receiving idle<br />

actions.<br />

Function key (F1-F24) was pressed. DlgItem has the focus. SuppValue is the function key number and the


142<br />

shift/control/alt key state.<br />

Regular function keys range from 1 to 24.<br />

Shift function keys have &H100 added.<br />

Control function keys have &H200 added.<br />

Alt function keys have &H400 added.<br />

(Alt-F4 closes the dialog and is never passed to the Dialog Function.)<br />

See Also: Begin Dialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Hello"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Debug.Print DlgItem$;"=""";DlgText$(DlgItem$);""""<br />

Debug.Print "SuppValue=";SuppValue%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

If DlgItem$ = "Hello" Then<br />

MsgBox "Hello"<br />

DialogFunc% = True 'do not exit the dialog<br />

End If<br />

Case 4 ' Focus changed<br />

Debug.Print "DlgFocus=""";DlgFocus();""""<br />

Case 6 ' Function key<br />

If SuppValue And &H100 Then Debug.Print "Shift-";<br />

If SuppValue And &H200 Then Debug.Print "Ctrl-";<br />

If SuppValue And &H400 Then Debug.Print "Alt-";<br />

Debug.Print "F" & (SuppValue And &HFF)<br />

End Select<br />

End Function<br />

Dialog Instruction/Function<br />

Syntax<br />

Dialog dialogvar[, default]<br />

-or-<br />

Dialog(dialogvar[, default])<br />

Group<br />

User Input


Description<br />

Display the dialog associated with dialogvar. The initial values of the dialog fields are provided by dialogvar. If the<br />

OK button or any push button is pressed then the fields in dialog are copied to the dialogvar. The Dialog( ) function<br />

returns a value indicating which button was pressed. (See the result table below.)<br />

Parameter Description<br />

dlgvar This variable that holds the values of the fields in a dialog. Use field to access<br />

individual fields in a dialog variable.<br />

default This numeric value indicates which button is the default button. (Pressing the Enter<br />

key on a non-button pushes the default button.) Use -2 to indicate that there is no<br />

default button. Other possible values are shown the result table below. If this value<br />

is omitted then the first PushButton, OKButton or CancelButton is the default button.<br />

Result Description<br />

-1 OK button was pressed.<br />

0 Cancel button was pressed.<br />

>0 Nth push button was pressed.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

Dim definition<br />

[lower To] upper<br />

Array dimension. If lower is omitted then the lower bound is zero or one depending on the Option Base setting.<br />

(The lower bound of an array element in a Type definition is not affected by the Option Base setting.) upper must<br />

be at least as big as lower.<br />

Dim A(100 To 200) '101 values<br />

Note: For ReDim the lower and upper may be any valid expression. Otherwise, lower and upper must be constant<br />

expressions.<br />

Dim Definition<br />

Syntax<br />

Dim [WithEvents] name[type][([dim[, ...]])][As [New] type][, ...]<br />

Group<br />

Declaration<br />

143


Description<br />

Dimension var array(s) using the dims to establish the minimum and maximum index value for each dimension. If<br />

the dims are omitted then a scalar (single value) variable is defined. A dynamic array is declared using ( ) without<br />

any dims. It must be ReDimensioned before it can be used.<br />

See Also: Begin Dialog, Dialog, Option Base, Private, Public, ReDim, Static, WithEvents.<br />

Example<br />

Sub DoIt(Size)<br />

Dim C0,C1(),C2(2,3)<br />

ReDim C1(Size) ' dynamic array<br />

C0 = 1<br />

C1(0) = 2<br />

C2(0,0) = 3<br />

Debug.Print C0;C1(0);C2(0,0) ' 1 2 3<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

DoIt 1<br />

End Sub<br />

Dir$ Function<br />

Syntax<br />

Dir[$]([Pattern$][, AttribMask])<br />

Group<br />

File<br />

Description<br />

Scan a directory for the first file matching Pattern$.<br />

Parameter Description<br />

Pattern$ This string value is the path and name of the file search pattern. If this is omitted<br />

then continue scanning with the previous pattern. Each macro has its own<br />

independent search. A path relative to the current directory can be used.<br />

AttribMask This numeric value controls which files are found. A file with an attribute that<br />

matches will be found.<br />

See Also: GetAttr( ).<br />

Example<br />

Sub Main<br />

F$ = Dir$("*.*")<br />

While F$ ""<br />

Debug.Print F$<br />

F$ = Dir$()<br />

Wend<br />

End Sub<br />

144


DlgControlId Function<br />

Syntax<br />

DlgControlId(DlgItem|$)<br />

Group<br />

Dialog Function<br />

Description<br />

Return the field's window id.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Hello"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

If DlgItem$ = "Hello" Then<br />

DialogFunc% = True 'do not exit the dialog<br />

End If<br />

Case 4 ' Focus changed<br />

Debug.Print "DlgFocus=""";DlgFocus();""""<br />

Debug.Print "DlgControlId(";DlgItem$;")=";<br />

Debug.Print DlgControlId(DlgItem$)<br />

End Select<br />

End Function<br />

145


DlgCount Function<br />

Syntax<br />

DlgCount()<br />

Group<br />

Dialog Function<br />

Description<br />

Return the number of dialog items in the dialog.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Debug.Print "DlgCount=";DlgCount() ' 3<br />

End Select<br />

End Function<br />

DlgEnd Instruction<br />

Syntax<br />

DlgEnd ReturnCode<br />

Group<br />

Dialog Function<br />

Description<br />

Set the return code for the Dialog Function and close the user dialog.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

ReturnCode Return this numeric value.<br />

146


Example<br />

Sub Main<br />

Begin Dialog UserDialog 210,120,.DialogFunc<br />

Text 10,10,190,15,"Please push the Close button"<br />

OKButton 30,90,60,20<br />

CheckBox 120,90,60,20,"&Close",.CheckBox1<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "CheckBox1"<br />

DlgEnd 1000<br />

End Select<br />

End Select<br />

End Function<br />

DlgEnable Instruction/Function<br />

Syntax<br />

DlgEnable DlgItem|$[, Enable]<br />

-or-<br />

DlgEnable(DlgItem|$)<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Enable or disable DlgItem|$.<br />

Function: Return True if DlgItem|$ is enabled.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Note: Use -1 to enable or disable all the dialog items at once.<br />

Enable It this numeric value is True then enable DlgItem|$. Otherwise, disable it. If this<br />

omitted then toggle it.<br />

Example<br />

147


Sub Main<br />

Begin Dialog UserDialog 210,120,.DialogFunc<br />

Text 10,10,190,15,"Please push the OKButton"<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Disable"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "Disable"<br />

DlgEnable "Text",False<br />

DialogFunc% = True 'do not exit the dialog<br />

Case "Enable"<br />

DlgText DlgItem$,"&Disable"<br />

DlgEnable "Text",True<br />

DialogFunc% = True 'do not exit the dialog<br />

End Select<br />

End Select<br />

End Function<br />

DlgFocus Instruction/Function<br />

Syntax<br />

DlgFocus DlgItem|$<br />

-or-<br />

DlgFocus[$]()<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Move the focus to this DlgItem|$.<br />

Function: Return the field name which has the focus as a string.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Example<br />

Sub Main<br />

148


Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Hello"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

If DlgItem$ = "Hello" Then<br />

MsgBox "Hello"<br />

DialogFunc% = True 'do not exit the dialog<br />

End If<br />

Case 4 ' Focus changed<br />

Debug.Print "DlgFocus=""";DlgFocus();""""<br />

End Select<br />

End Function<br />

DlgListBoxArray Instruction/Function<br />

Syntax<br />

DlgListBoxArray DlgItem|$, StrArray$( )<br />

-or-<br />

DlgListBoxArray(DlgItem|$[, StrArray$( )])<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Set the list entries for DlgItem|$.<br />

Function: Return the number entries in DlgItem|$'s list.<br />

This instruction/function must be called directly or indirectly from a dialogfunc. The DlgItem|$ should refer to a<br />

ComboBox, DropListBox, ListBox, or MultiListBox.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

StrArray$( ) Set the list entries of DlgItem|$. This one-dimensional array of strings establishes<br />

the list of choices. All the non-null elements of the array are used.<br />

Example<br />

Dim lists$()<br />

149


C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

ReDim lists$(0)<br />

lists$(0) = "List 0"<br />

Begin Dialog UserDialog 200,119,.DialogFunc<br />

Text 10,7,180,14,"Please push the OK button"<br />

ListBox 10,21,180,63,lists(),.list<br />

OKButton 30,91,40,21<br />

PushButton 110,91,60,21,"&Change"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.list = 2<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.list<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Select Case Action%<br />

Case 2 ' Value changing or button pressed<br />

If DlgItem$ = "Change" Then<br />

Dim N As Integer<br />

N = UBound(lists$)+1<br />

ReDim Preserve lists$(N)<br />

lists$(N) = "List " & N<br />

DlgListBoxArray "list",lists$()<br />

DialogFunc% = True 'do not exit the dialog<br />

End If<br />

End Select<br />

End Function<br />

DlgName Function<br />

Syntax<br />

DlgName[$](DlgItem)<br />

Group<br />

Dialog Function<br />

Description<br />

Return the field name of the DlgItem number.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem This numeric value is the dialog item number. The first item is 0, second is 1, etc.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

150


OKButton 30,90,60,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

For I = 0 To DlgCount()-1<br />

Debug.Print I;DlgName(I)<br />

Next I<br />

End Select<br />

End Function<br />

DlgNumber Function<br />

Syntax<br />

DlgNumber(DlgItem$)<br />

Group<br />

Dialog Function<br />

Description<br />

Return the number of the DlgItem$. The first item is 0, second is 1, etc.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem$ This string value is the dialog item's field name.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 4 ' Focus changed<br />

Debug.Print DlgItem$;"=";DlgNumber(DlgItem$)<br />

151


End Select<br />

End Function<br />

DlgSetPicture Instruction<br />

Syntax<br />

DlgSetPicture DlgItem|$, FileName, Type<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Set the file name for DlgItem|$.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

FileName Set the file name of DlgItem|$ to this string value.<br />

Type This numeric value indicates the type of bitmap used. See below.<br />

Type Effect<br />

0 FileName is the name of the bitmap file. If the file does not exist then "(missing picture)" is<br />

displayed.<br />

3 The clipboard's bitmap is displayed. Not supported.<br />

+16 Instead of displaying "(missing picture)" a run-time error occurs.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Picture 10,10,180,75,"",0,.Picture<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&View"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "View"<br />

FileName = GetFilePath("Bitmap","BMP")<br />

DlgSetPicture "Picture",FileName,0<br />

DialogFunc% = True 'do not exit the dialog<br />

End Select<br />

152


End Select<br />

End Function<br />

DlgText Instruction/Function<br />

Syntax<br />

DlgText DlgItem|$, Text<br />

-or-<br />

DlgText[$](DlgItem|$)<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Set the text for DlgItem|$.<br />

Function: Return the text from DlgItem|$.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name. Note: Use -1<br />

to access the dialog's title.<br />

Text Set the text of DlgItem|$ to this string value.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Now"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "Now"<br />

DlgText "Text",CStr(Now)<br />

DialogFunc% = True 'do not exit the dialog<br />

End Select<br />

End Select<br />

End Function<br />

153


DlgType Function<br />

Syntax<br />

DlgType[$](DlgItem|$)<br />

Group<br />

Dialog Function<br />

Description<br />

Return a string value indicating the type of the DlgItem|$. One of: "CancelButton", "CheckBox", "ComboBox",<br />

"DropListBox", "GroupBox", "ListBox", "MultiListBox", "OKButton", "OptionButton", "OptionGroup", "PushButton",<br />

"Text", "TextBox".<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

For I = 0 To DlgCount()-1<br />

Debug.Print I;DlgType(I)<br />

Next I<br />

End Select<br />

End Function<br />

DlgValue Instruction/Function<br />

Syntax<br />

DlgValue DlgItem|$, Value<br />

-or-<br />

DlgValue(DlgItem|$)<br />

154


Group<br />

Dialog Function<br />

Description<br />

Instruction: Set the numeric value DlgItem|$.<br />

Function: Return the numeric value for DlgItem|$. (A MultiListBox user dialog item returns an array.)<br />

This instruction/function must be called directly or indirectly from a dialogfunc. The DlgItem|$ should refer to a<br />

CheckBox, ComboBox, DropListBox, ListBox, MultiListBox, or OptionGroup.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Value Set the text of DlgItem|$ to this numeric value. (A MultiListBox user dialog item uses<br />

an array.)<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 150,147,.DialogFunc<br />

GroupBox 10,7,130,77,"Direction",.Field1<br />

PushButton 100,28,30,21,"&Up"<br />

PushButton 100,56,30,21,"&Dn"<br />

OptionGroup .Direction<br />

OptionButton 20,21,80,14,"&North",.North<br />

OptionButton 20,35,80,14,"&South",.South<br />

OptionButton 20,49,80,14,"&East",.East<br />

OptionButton 20,63,80,14,"&West",.West<br />

OKButton 10,91,130,21<br />

CancelButton 10,119,130,21<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg<br />

MsgBox "Direction=" & dlg.Direction<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "Up"<br />

DlgValue "Direction",0<br />

DialogFunc% = True 'do not exit the dialog<br />

Case "Dn"<br />

DlgValue "Direction",1<br />

DialogFunc% = True 'do not exit the dialog<br />

End Select<br />

End Select<br />

End Function<br />

155


dlgvar definition<br />

A dialog variable holds values for fields in the dialog. Dialog variables are declared using Dim dlgvar As UserDialog.<br />

DlgVisible Instruction/Function<br />

Syntax<br />

DlgVisible DlgItem|$[, Visible]<br />

-or-<br />

DlgVisible(DlgItem|$)<br />

Group<br />

Dialog Function<br />

Description<br />

Instruction: Show or hide DlgItem|$.<br />

Function: Return True if DlgItem|$ is visible.<br />

This instruction/function must be called directly or indirectly from a dialogfunc.<br />

Parameter Description<br />

DlgItem|$ If this is a numeric value then it is the dialog item number. The first item is 0, second<br />

is 1, etc. If this is a string value then it is the dialog item's field name.<br />

Enable It this numeric value is True then show DlgItem|$. Otherwise, hide it. If this omitted<br />

then toggle it.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120,.DialogFunc<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,40,180,15,.Text<br />

OKButton 30,90,60,20<br />

PushButton 110,90,60,20,"&Hide"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

C:\ABCTemp\vbs\Function_Definition.htm<br />

Function DialogFunc%(DlgItem$, Action%, SuppValue%)<br />

Debug.Print "Action=";Action%<br />

Select Case Action%<br />

Case 1 ' Dialog box initialization<br />

Beep<br />

Case 2 ' Value changing or button pressed<br />

Select Case DlgItem$<br />

Case "Hide"<br />

DlgText DlgItem$,"&Show"<br />

DlgVisible "Text",False<br />

DialogFunc% = True 'do not exit the dialog<br />

Case "Show"<br />

156


DlgText DlgItem$,"&Hide"<br />

DlgVisible "Text",True<br />

DialogFunc% = True 'do not exit the dialog<br />

End Select<br />

End Select<br />

End Function<br />

Do Statement<br />

Syntax<br />

Do<br />

statements<br />

Loop<br />

-or-<br />

Do {Until|While} condexpr<br />

statements<br />

Loop<br />

-or-<br />

Do<br />

statements<br />

Loop {Until|While} condexpr<br />

Group<br />

Flow Control<br />

Description<br />

Form 1: Do statements forever. The loop can be exited by using Exit or Goto.<br />

Form 2: Check for loop termination before executing the loop the first time.<br />

Form 3: Execute the loop once and then check for loop termination.<br />

Loop Termination:<br />

Until condexpr: Do statements until condexpr is True.<br />

While condexpr: Do statements while condexpr is True.<br />

See Also: For, For Each, Exit Do, While.<br />

Example<br />

Sub Main<br />

I = 2<br />

Do<br />

I = I*2<br />

Loop Until I > 10<br />

Debug.Print I ' 16<br />

End Sub<br />

157


DoEvents Instruction<br />

Syntax<br />

DoEvents<br />

Group<br />

Miscellaneous<br />

Description<br />

This instruction allows other applications to process events.<br />

Example<br />

Sub Main<br />

DoEvents ' let other apps work<br />

End Sub<br />

DropListBox Dialog Item Definition<br />

Syntax<br />

DropListBox X, Y, DX, DY, StrArray$( ), .Field[, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a drop-down listbox item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the non-null<br />

elements of the array are used.<br />

Field The value of the drop-down list box is accessed via this field. It is the index of the<br />

StrArray$( ) var.<br />

Options This numeric value controls the type of drop-down list box. Choose one value from<br />

following table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 Text box is not editable and list is not sorted.<br />

1 Text box is editable and list is not sorted.<br />

2 Text box is not editable and list is sorted.<br />

3 Text box is editable and list is sorted.<br />

158


See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Dim lists$(3)<br />

lists$(0) = "List 0"<br />

lists$(1) = "List 1"<br />

lists$(2) = "List 2"<br />

lists$(3) = "List 3"<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

DropListBox 10,25,180,60,lists$(),.list1<br />

DropListBox 10,50,180,60,lists$(),.list2,1<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.list1 = 2 ' list1 is a numeric field<br />

dlg.list2 = "xxx" ' list2 is a string field<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print lists$(dlg.list1)<br />

Debug.Print dlg.list2<br />

End Sub<br />

End Instruction<br />

Syntax<br />

End<br />

Group<br />

Flow Control<br />

Description<br />

The end instruction causes the macro to terminate immediately. If the macro was run by another macro using the<br />

MacroRun instruction then that macro continues on the instruction following the MacroRun.<br />

Example<br />

Sub DoSub<br />

L$ = UCase$(InputBox$("Enter End:"))<br />

If L$ = "END" Then End<br />

Debug.Print "End was not entered."<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Debug.Print "Before DoSub"<br />

DoSub<br />

Debug.Print "After DoSub"<br />

End Sub<br />

159


Enum Definition<br />

Syntax<br />

[ | Private | Public ] _<br />

Enum name<br />

elem [ = value]<br />

[...]<br />

End Enum<br />

Group<br />

Declaration<br />

Description<br />

Define a new userenum. Each elem defines an element of the enum. If value is given then that is the element's<br />

value. The value can be any constant integer expression. If value is omitted then the element's value is one more<br />

than the previous element's value. If there is no previous element then zero is used.<br />

Enum defaults to Public if neither Private or Public is specified.<br />

Example<br />

Enum Days<br />

Monday<br />

Tuesday<br />

Wednesday<br />

Thursday<br />

Friday<br />

Saturday<br />

Sunday<br />

End Enum<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Dim D As Days<br />

For D = Monday To Friday<br />

Debug.Print D ' 0 through 4<br />

Next D<br />

End Sub<br />

Environ Instruction/Function<br />

Syntax<br />

Environ[$](Index)<br />

-or-<br />

Environ[$](Name)<br />

Group<br />

Miscellaneous<br />

Description<br />

160


Return an environment string.<br />

Parameter Description<br />

Index Return this environment string's value. If there is no environment string at this index<br />

a null string is returned. Indexes start at one.<br />

Name Return this environment string's value. If the environment string can't be found a<br />

null string is returned.<br />

Example<br />

Sub Main<br />

Debug.Print Environ("Path")<br />

End Sub<br />

EOF Function<br />

Syntax<br />

EOF(StreamNum)<br />

Group<br />

File<br />

Description<br />

Return True if StreamNum is at the end of the file.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

While Not EOF(1)<br />

Line Input #1,L$<br />

Debug.Print L$<br />

Wend<br />

Close #1<br />

End Sub<br />

Erase Instruction<br />

Syntax<br />

Erase arrayvar[, ...]<br />

-or-<br />

Erase usertypevar.elem[, ...]<br />

Group<br />

161


Assignment<br />

Description<br />

Reset arrayvar or user defined type array element to zero. (Dynamic arrays are reset to undimensioned arrays.)<br />

String arrays values are set to a null string. arrayvar must be declared as an array.<br />

Declare with Dim, Private, Public or Static.<br />

Declare as a parameter of Sub, Function or Property definition.<br />

Example<br />

Sub Main<br />

Dim X%(2)<br />

X%(1) = 1<br />

Erase X%<br />

Debug.Print X%(1) ' 0<br />

End Sub<br />

Err Object<br />

Syntax<br />

Err<br />

Group<br />

Error Handling<br />

Description<br />

Set Err to zero to clear the last error event. Err in an expression returns the last error code. Add vbObjectError to<br />

your error number in ActiveX Automation objects. Use Err.Raise or Error to trigger an error event.<br />

Err[.Number]<br />

This is the error code for the last error event. Set it to zero (or use Err.Clear) to clear the last error condition. Use<br />

Error or Err.Raise to trigger an error event. This is the default property.<br />

Err.Description<br />

This string is the description of the last error event.<br />

Err.Source<br />

This string is the error source file name of the last error event.<br />

Err.HelpFile<br />

This string is the help file name of the last error event.<br />

Err.HelpContext<br />

This number is the help context id of the last error event.<br />

Err.Clear<br />

Clear the last error event.<br />

Err.Raise [Number:=]errorcode _<br />

[, [Source:=]source] _<br />

162


[, [Description:=]errordesc] _<br />

[, [HelpFile:=]helpfile] _<br />

[, [HelpContext:=]context]<br />

Raise an error event.<br />

Err.LastDLLError<br />

For 32 bit windows this returns the error code for the last DLL call (see Declare). For 16 bit windows this always<br />

returns 0.<br />

Example<br />

Sub Main<br />

On Error GoTo Problem<br />

Err = 1 ' set to error #1 (handler not triggered)<br />

Exit Sub<br />

Problem: ' error handler<br />

Error Err ' halt macro with message<br />

End Sub<br />

Error Instruction/Function<br />

Syntax<br />

Error ErrorCode<br />

-or-<br />

Error[$]([ErrorCode])<br />

Group<br />

Error Handling<br />

Description<br />

Instruction: Signal error ErrorCode. This triggers error handling just like a real error. The current procedure's error<br />

handler is activated, unless it is already active or there isn't one. In that case the calling procedure's error handler<br />

is tried. (Use Err.Raise to provide complete error information.)<br />

Function: The Error( ) function returns the error text string.<br />

Parameter Description<br />

ErrorCode This is the error number.<br />

Example<br />

Sub Main<br />

On Error GoTo Problem<br />

Err.Raise 1 ' simulate error #1<br />

Exit Sub<br />

Problem: ' error handler<br />

Debug.Print "Error$=";Error$<br />

Resume Next<br />

End Sub<br />

163


Eval Function<br />

Syntax<br />

Eval(Expr[, Depth])<br />

Group<br />

Miscellaneous<br />

Description<br />

Return the value of the string expression as evaluated.<br />

Parameter Description<br />

Expr Evaluate this string value.<br />

Depth This integer value indicates how deep into the stack to locate the local variables. If<br />

Depth = 0 then use the current procedure. If this value is omitted then the depth is<br />

0.<br />

Example<br />

Sub Main<br />

Dim X As String<br />

X = "Hello"<br />

Debug.Print Eval("X") 'Hello<br />

A<br />

End Sub<br />

Sub A<br />

Dim X As String<br />

X = "Bye"<br />

Debug.Print Eval("X") 'Bye<br />

Debug.Print Eval("X",1) 'Hello<br />

End Sub<br />

Exit Instruction<br />

Syntax<br />

Exit {All|Do|For|Function|Property|Sub|While}<br />

Group<br />

Flow Control<br />

Description<br />

The exit instruction causes the macro to continue with out doing some or all of the remaining instructions.<br />

Exit Description<br />

All Exit all macros.<br />

Do Exit the Do loop.<br />

For Exit the For of For Each loop.<br />

164


Function Exit the Function block. Note: This instruction clears the Err and sets Error$ to null.<br />

Property Exit the Property block. Note: This instruction clears the Err and sets Error$ to null.<br />

Sub Exit the Sub block. Note: This instruction clears the Err and sets Error$ to null.<br />

While Exit the While loop.<br />

Example<br />

Sub Main<br />

L$ = InputBox$("Enter Do, For, While, Sub or All:")<br />

Debug.Print "Before DoSub"<br />

DoSub UCase$(L$)<br />

Debug.Print "After DoSub"<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub DoSub(L$)<br />

Do<br />

If L$ = "DO" Then Exit Do<br />

I = I+1<br />

Loop While I < 10<br />

If I = 0 Then Debug.Print "Do was entered"<br />

C:\ABCTemp\vbs\For_Statement.htm<br />

For I = 1 To 10<br />

If L$ = "FOR" Then Exit For<br />

Next I<br />

If I = 1 Then Debug.Print "For was entered"<br />

I = 10<br />

While I > 0<br />

If L$ = "WHILE" Then Exit While<br />

I = I-1<br />

Wend<br />

If I = 10 Then Debug.Print "While was entered"<br />

C:\ABCTemp\vbs\If_Statement.htm<br />

If L$ = "SUB" Then Exit Sub<br />

Debug.Print "Sub was not entered."<br />

If L$ = "ALL" Then Exit All<br />

Debug.Print "All was not entered."<br />

End Sub<br />

Exp Function<br />

Syntax<br />

Exp(Num)<br />

Group<br />

Math<br />

Description<br />

Return the exponential.<br />

Parameter Description<br />

Num Return e raised to the power of this numeric value. The value e is approximately<br />

165


Example<br />

166<br />

2.718282.<br />

Sub Main<br />

Debug.Print Exp(1) ' 2.718281828459<br />

End Sub<br />

Expr definition<br />

An expression that returns the appropriate result.<br />

Field definition<br />

Use .field to access individual fields in a dialog variable.<br />

dlg.Name$<br />

dlg.ZipCode<br />

FileAttr Function<br />

Syntax<br />

FileAttr(StreamNum, ReturnValue)<br />

Group<br />

File<br />

Description<br />

Return StreamNum's open mode or file handle.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

ReturnValue 1 - return the mode used to open the file: 1=Input, 2=Output, 4=Random,<br />

8=Append, 32=Binary<br />

2 - return the file handle<br />

See Also: Open.<br />

Example<br />

Sub Main<br />

Open "XXX" For Output As #1<br />

Debug.Print FileAttr(1,1) ' 2<br />

Close #1<br />

End Sub


FileCopy Instruction<br />

Syntax<br />

FileCopy FromName$, ToName$<br />

Group<br />

File<br />

Description<br />

Copy a file.<br />

Parameter Description<br />

FromName$ This string value is the path and name of the source file. A path relative to the<br />

current directory can be used.<br />

ToName$ This string value is the path and name of the destination file. A path relative to the<br />

current directory can be used.<br />

Example<br />

Sub Main<br />

FileCopy "C:\AUTOEXEC.BAT","C:\AUTOEXEC.BAK"<br />

End Sub<br />

FileDateTime Function<br />

Syntax<br />

FileDateTime(Name$)<br />

Group<br />

File<br />

Description<br />

Return the date and time file Name$ was last changed as a date value. If the file does not exist then a run-time<br />

error occurs.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

Example<br />

Sub Main<br />

F$ = Dir$("*.*")<br />

While F$ ""<br />

Debug.Print F$;" ";FileDateTime(F$)<br />

F$ = Dir$()<br />

167


Wend<br />

End Sub<br />

FileLen Function<br />

Syntax<br />

FileLen(Name$)<br />

Group<br />

File<br />

Description<br />

Return the length of file Name$. If the file does not exist then a run-time error occurs.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

Example<br />

Sub Main<br />

F$ = Dir$("*.*")<br />

While F$ ""<br />

Debug.Print F$;" ";FileLen(F$)<br />

F$ = Dir$()<br />

Wend<br />

End Sub<br />

Fix Function<br />

Syntax<br />

Fix(Num)<br />

Group<br />

Math<br />

Description<br />

Return the integer value.<br />

Parameter Description<br />

Num Return the integer portion of this numeric value. The number is truncated. Positive<br />

numbers return the next lower integer. Negative numbers return the next higher<br />

integer. If this value is Null then Null is returned.<br />

Example<br />

Sub Main<br />

168


Debug.Print Fix(9.9) ' 9<br />

Debug.Print Fix(0) ' 0<br />

Debug.Print Fix(-9.9) '-9<br />

End Sub<br />

For Statement<br />

Syntax<br />

For Num = First To Last [Step Inc]<br />

statements<br />

Next [Num]<br />

Group<br />

Flow Control<br />

Description<br />

Execute statements while Num is in the range First to Last.<br />

Parameter Description<br />

Num This is the iteration variable.<br />

First Set Num to this value initially.<br />

Last Continue looping while Num is in the range. See Step below.<br />

Step If this numeric value is greater than zero then the for loop continues as long as Num<br />

is less than or equal to Last. If this numeric value is less than zero then the for loop<br />

continues as long as Num is greater than or equal to Last. If this is omitted then one<br />

is used.<br />

See Also: Do, For Each, Exit For, While.<br />

Example<br />

Sub Main<br />

For I = 1 To 2000 Step 100<br />

Debug.Print I;I+I;I*I<br />

Next I<br />

End Sub<br />

For Each Statement<br />

Syntax<br />

For Each var In items<br />

statements<br />

Next [var]<br />

Group<br />

Flow Control<br />

169


Description<br />

Execute statements for each item in items.<br />

Parameter Description<br />

ar This is the iteration variable.<br />

items This is the collection of items to be done.<br />

See Also: Do, For, Exit For, While.<br />

Example<br />

Sub Main<br />

Dim Document As Object<br />

For Each Document In App.Documents<br />

Debug.Print Document.Title<br />

Next Document<br />

End Sub<br />

Format$ Function<br />

Syntax<br />

Format[$](expr[, form$], [firstday], _<br />

[firstweek])<br />

Group<br />

String<br />

Description<br />

Return the formatted string representation of expr.<br />

Parameter Description<br />

expr Return the formatted string representation of this numeric value.<br />

form Format expr using to this string value. If this is omitted then return the expr as a<br />

string.<br />

firstday Format using this day as the first day of the week. If this is omitted then the<br />

vbSunday is used. (Only supported for Win32.)<br />

firstweek Format using this week as the first week of the year. If this is omitted then the<br />

vbFirstJan1 is used. (Only supported for Win32.)<br />

firstday Value Description<br />

vbUse<strong>System</strong>FirstDay 0 Use the systems first day of the week.<br />

vbSunday 1 Sunday (default)<br />

vbMonday 2 Monday<br />

vbTuesday 3 Tuesday<br />

vbWednesday 4 Wednesday<br />

vbThursday 5 Thursday<br />

vbFriday 6 Friday<br />

vbSaturday 7 Saturday<br />

firstweek Value Description<br />

vbUse<strong>System</strong> 0 Use the systems first week of the year<br />

vbFirstJan1 1 The week that January 1 occurs in. This is the default value.<br />

170


vbFirstFourDays 2 The first week that has at least four days in the year.<br />

vbFirstFullWeek 3 The first week that entirely in the year.<br />

See Also: Predefined Date Format, Predefined Number Format, User defined Date Format, User defined Number<br />

Format, User defined Text Format.<br />

FreeFile Function<br />

Syntax<br />

FreeFile[( )]<br />

Group<br />

File<br />

Description<br />

Return the next unused shared stream number (greater than or equal to 256). Streams 1 through 255 are private<br />

to each macro. Streams 256 through 511 are shared by all macros.<br />

Example<br />

Sub Main<br />

Debug.Print FreeFile ' 256<br />

FN = FreeFile<br />

Open "XXX" For Output As #FN<br />

Debug.Print FreeFile ' 257<br />

Close #FN<br />

Debug.Print FreeFile ' 256<br />

End Sub<br />

Friend Keyword<br />

Group<br />

Declaration<br />

Description<br />

Friend Functions, Propertys and Subs in a module are available in all other macros/modules that access it. Friends<br />

are not accessible via Object variables.<br />

Function Definition<br />

Syntax<br />

171


[ | Private | Public | Friend ] _<br />

Function name[type][([param[, ...]])] [As type[()]]<br />

statements<br />

End Function<br />

Group<br />

Declaration<br />

Description<br />

User defined function. The function defines a set of statements to be executed when it is called. The values of the<br />

calling arglist are assigned to the params. Assigning to name[type] sets the value of the function result.<br />

Function defaults to Public if Private, Public or Friend are not is specified.<br />

See Also: Declare, Property, Sub.<br />

Example<br />

Function Power(X,Y)<br />

P = 1<br />

For I = 1 To Y<br />

P = P*X<br />

Next I<br />

Power = P<br />

End Function<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Debug.Print Power(2,8) ' 256<br />

End Sub<br />

Get Instruction<br />

Syntax<br />

Get StreamNum, [RecordNum], var<br />

Group<br />

File<br />

Description<br />

Get a variable's value from StreamNum.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

RecordNum For Random mode files this is the record number. The first record is 1. Otherwise, it<br />

is the byte position. The first byte is 1. If this is omitted then the current position (or<br />

record number) is used.<br />

ar This variable value is read from the file. For a fixed length variable (like Long) the<br />

number of bytes required to restore the variable are read. For a Variant variable two<br />

bytes are read which describe its type and then the variable value is read<br />

accordingly. For a usertype variable each field is read in sequence. For an array<br />

172


See Also: Open, Put.<br />

Example<br />

173<br />

variable each element is read in sequence. For a dynamic array variable the number<br />

of dimensions and range of each dimension is read prior to reading the array values.<br />

All binary data values are read from the file in little-endian format.<br />

Note: When reading a string (or a dynamic array) from a Binary mode file the length<br />

(or array dimension) information is not read. The current string length determines<br />

how much string data is read. The current array dimension determines how may<br />

array elements are read.<br />

Sub Main<br />

Dim V As Variant<br />

Open "SAVE_V.DAT" For Binary Access Read As #1<br />

Get #1, , V<br />

Close #1<br />

End Sub<br />

GetAllSettings Function<br />

Syntax<br />

GetAllSettings(AppName$, Section$, Key$)<br />

Group<br />

Settings<br />

Description<br />

Get all of Section's settings in project AppName. Settings are returned in a Variant. Empty is returned if there are<br />

no keys in the section. Otherwise, the Variant contains a two dimension array: (I,0) is the key and (I,1) is the<br />

setting. Win16 and Win32s store settings in a .ini file named AppName. Win32 stores settings in the registration<br />

database.<br />

Parameter Description<br />

AppName$ This string value is the name of the project which has this Section and Key.<br />

Section$ This string value is the name of the section of the project settings.<br />

Example<br />

Sub Main<br />

SaveSetting "MyApp","Font","Size",10<br />

SaveSetting "MyApp","Font","Name","Courier"<br />

Settings = GetAllSettings("MyApp","Font")<br />

For I = LBound(Settings) To UBound(Settings)<br />

Debug.Print Settings(I,0); "="; Settings(I,1)<br />

Next I<br />

DeleteSetting "MyApp","Font"<br />

End Sub


GetAttr Function<br />

Syntax<br />

GetAttr(Name$)<br />

Group<br />

File<br />

Description<br />

Return the attributes for file Name$. If the file does not exist then a run-time error occurs.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

Example<br />

Sub Main<br />

F$ = Dir$("*.*")<br />

While F$ ""<br />

Debug.Print F$;" ";GetAttr(F$)<br />

F$ = Dir$()<br />

Wend<br />

End Sub<br />

GetFilePath$ Function<br />

Syntax<br />

GetFilePath[$]([DefName$], [DefExt$], [DefDir$], _<br />

[Title$], [Option])<br />

Group<br />

User Input<br />

Description<br />

Put up a dialog box and get a file path from the user. The returned string is a complete path and file name. If the<br />

cancel button is pressed then a null string is returned.<br />

Parameter Description<br />

DefName$ Set the initial File Name in the to this string value. If this is omitted then *.DefExt$ is<br />

used.<br />

DefExt$ Initially show files whose extension matches this string value. (Multiple extensions<br />

can be specified by using ";" as the separator.) If this is omitted then * is used.<br />

DefDir$ This string value is the initial directory. If this is omitted then the current directory is<br />

used.<br />

Title$ This string value is the title of the dialog. If this is omitted then ''Open" is used.<br />

Option This numeric value determines the file selection options. If this is omitted then zero<br />

is used. See table below.<br />

Option Effect<br />

174


0 Only allow the user to select a file that exists.<br />

1 Confirm creation when the user selects a file that does not exist.<br />

2 Allow the user to select any file whether it exists or not.<br />

3 Confirm overwrite when the user selects a file that exists.<br />

+4 Selecting a different directory changes the application's current directory.<br />

Example<br />

Sub Main<br />

Debug.Print GetFilePath$()<br />

End Sub<br />

GetObject Function<br />

Syntax<br />

GetObject([File$][, Class$])<br />

Group<br />

Object<br />

Description<br />

Get an existing object of type Class$ from File$. Use Set to assign the returned object to an object variable.<br />

Parameter Description<br />

File$ This is the file where the object resides. If this is omitted then the currently active<br />

object for Class$ is returned.<br />

Class$ This string value is the application's registered class name. If this application is not<br />

currently active it will be started. If this is omitted then the application associated<br />

with the file's extension will be started.<br />

Example<br />

Sub Main<br />

Dim App As Object<br />

Set App = GetObject(,"WinWrap.CppDemoApplication")<br />

App.Move 20,30 ' move icon to 20,30<br />

Set App = Nothing<br />

App.Quit ' run-time error (no object)<br />

End Sub<br />

GetSetting Function<br />

Syntax<br />

GetSetting[$](AppName$, Section$, Key$[, Default$])<br />

Group<br />

175


Settings<br />

Description<br />

Get the setting for Key in Section in project AppName. Win16 and Win32s store settings in a .ini file named<br />

AppName. Win32 stores settings in the registration database.<br />

Parameter Description<br />

AppName$ This string value is the name of the project which has this Section and Key.<br />

Section$ This string value is the name of the section of the project settings.<br />

Key$ This string value is the name of the key in the section of the project settings.<br />

Default$ Return this string value if no setting has been saved. If this is omitted then a null<br />

string is used.<br />

Example<br />

Sub Main<br />

SaveSetting "MyApp","Font","Size",10<br />

Debug.Print GetSetting("MyApp","Font","Size") ' 10<br />

End Sub<br />

Goto Instruction<br />

Syntax<br />

GoTo label<br />

Group<br />

Flow Control<br />

Description<br />

Go to the label and continue execution from there. Only labels in the current user defined procedure are accessible.<br />

Example<br />

Sub Main<br />

X = 2<br />

Loop:<br />

X = X*X<br />

If X < 100 Then GoTo Loop<br />

Debug.Print X ' 256<br />

End Sub<br />

GroupBox Dialog Item Definition<br />

Syntax<br />

GroupBox X, Y, DX, DY, Title$[, .Field]<br />

Group<br />

176


User Dialog<br />

Description<br />

Define a groupbox item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ This string value is the title of the group box.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this identifer is omitted then the first two words of the title are used.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

GroupBox 10,25,180,60,"Group box"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

Hex$ Function<br />

Syntax<br />

Hex[$](Num)<br />

Group<br />

String<br />

Description<br />

Return a hex string.<br />

Parameter Description<br />

Num Return a hex encoded string for this numeric value.<br />

See Also: Oct$( ), Str$( ), Val( ).<br />

Example<br />

Sub Main<br />

Debug.Print Hex$(15) 'F<br />

End Sub<br />

177


Hour Function<br />

Syntax<br />

Hour(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the hour of the day (0 to 23).<br />

Parameter Description<br />

dateexpr Return the hour of the day for this date value. If this value is Null then Null is<br />

returned.<br />

See Also: Minute( ), Second( ), Time( ).<br />

Example<br />

Sub Main<br />

Debug.Print Hour(#12:00:01 AM#) ' 0<br />

End Sub<br />

If Statement<br />

Syntax<br />

If condexpr Then [instruction] [Else instruction]<br />

-or-<br />

If condexpr Then<br />

statements<br />

[ElseIf condexpr Then<br />

statements]...<br />

[Else<br />

statements]<br />

End If<br />

-or-<br />

If TypeOf objexpr Is objtype Then ...<br />

Group<br />

Flow Control<br />

Description<br />

Form 1: Single line if statement. Execute the instruction following the Then if condexpr is True. Otherwise, execute<br />

the instruction following the Else. The Else portion is optional.<br />

Form 2: The multiple line if is useful for complex ifs. Each if condexpr is checked in turn. The first True one causes<br />

178


the following statements to be executed. If all are False then the Else's statements are executed. The ElseIf and<br />

Else portions are optional.<br />

Form 3: If objexpr's type is the same type or a type descended from objtype the Then portion is executed.<br />

See Also: Select Case, Choose( ), IIf( ).<br />

Example<br />

Sub Main<br />

S = InputBox("Enter hello, goodbye, dinner or sleep:")<br />

S = UCase(S)<br />

If S = "HELLO" Then Debug.Print "come in"<br />

If S = "GOODBYE" Then Debug.Print "see you later"<br />

If S = "DINNER" Then<br />

Debug.Print "Please come in."<br />

Debug.Print "Dinner will be ready soon."<br />

ElseIf S = "SLEEP" Then<br />

Debug.Print "Sorry."<br />

Debug.Print "We are full for the night"<br />

End If<br />

End Sub<br />

IIf Function<br />

Syntax<br />

IIf(condexpr, TruePart, FalsePart)<br />

Group<br />

Miscellaneous<br />

Description<br />

Return the value of the parameter indicated by condexpr. Both TruePart and FalsePart are evaluated.<br />

Parameter Description<br />

condexpr If this value is True then return TruePart. Otherwise, return FalsePart.<br />

TruePart Return this value if condexpr is True.<br />

FalsePart Return this value if condexpr is False.<br />

See Also: If, Select Case, Choose( ).<br />

Example<br />

Sub Main<br />

Debug.Print IIf(1 > 0,"True","False") '"True"<br />

End Sub<br />

179


Input Instruction<br />

Syntax<br />

Input [#]StreamNum, var[, ...]<br />

Group<br />

File<br />

Description<br />

Get input from StreamNum and assign it to vars. Input values are comma delimited. Leading and trailing spaces<br />

are ignored. If the first char (following the leading spaces) is a quote (") then the string is terminated by an ending<br />

quote. Special values #NULL#, #FALSE#, #TRUE#, #date# and #ERROR number# are converted to their<br />

appropriate value and data type.<br />

See Also: Line Input, Print, Write.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

Input #1,A,B,C$<br />

Debug.Print A;B;C$<br />

Close #1<br />

End Sub<br />

Input$ Function<br />

Syntax<br />

Input[$](N, StreamNum)<br />

Group<br />

File<br />

Description<br />

Return N chars from StreamNum.<br />

Parameter Description<br />

N Read this many chars. If fewer than that many chars are left before the end of file<br />

then a run-time error occurs.<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

L = LOF(1)<br />

T$ = Input$(L,1)<br />

Close #1<br />

Debug.Print T$;<br />

180


End Sub<br />

InputBox$ Function<br />

Syntax<br />

InputBox[$](Prompt$[, Title$][, Default$][, XPos, YPos])<br />

Group<br />

User Input<br />

Description<br />

Display an input box where the user can enter a line of text. Pressing the OK button returns the string entered.<br />

Pressing the Cancel button returns a null string.<br />

Parameter Description<br />

Prompt$ Use this string value as the prompt in the input box.<br />

Title$ Use this string value as the title of the input box. If this is omitted then the input box<br />

does not have a title.<br />

Default$ Use this string value as the initial value in the input box. If this is omitted then the<br />

initial value is blank.<br />

XPos When the dialog is put up the left edge will be at this screen position. If this is omitted<br />

then the dialog will be centered.<br />

YPos When the dialog is put up the top edge will be at this screen position. If this is omitted<br />

then the dialog will be centered.<br />

Example<br />

Sub Main<br />

L$ = InputBox$("Enter some text:", _<br />

"Input Box Example","asdf")<br />

Debug.Print L$<br />

End Sub<br />

InStr Function<br />

Syntax<br />

InStr([Index, ]S1$, S2$)<br />

Group<br />

String<br />

Description<br />

Return the index where S2$ first matches S1$. If no match is found return 0.<br />

Note: A similar function, InStrB, returns the byte index instead.<br />

Parameter Description<br />

181


Index Start searching for S2$ at this index in S1$. If this is omitted then start searching<br />

from the beginning of S1$.<br />

S1$ Search for S2$ in this string value. If this value is Null then Null is returned.<br />

S2$ Search S1$ for this string value. If this value is Null then Null is returned.<br />

See Also: InStrRev( ), Left$( ), Len( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print InStr("Hello","l") ' 3<br />

End Sub<br />

InStr Function<br />

Syntax<br />

InStr([Index, ]S1$, S2$)<br />

Group<br />

String<br />

Description<br />

Return the index where S2$ first matches S1$. If no match is found return 0.<br />

Note: A similar function, InStrB, returns the byte index instead.<br />

Parameter Description<br />

Index Start searching for S2$ at this index in S1$. If this is omitted then start searching<br />

from the beginning of S1$.<br />

S1$ Search for S2$ in this string value. If this value is Null then Null is returned.<br />

S2$ Search S1$ for this string value. If this value is Null then Null is returned.<br />

See Also: InStrRev( ), Left$( ), Len( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print InStr("Hello","l") ' 3<br />

End Sub<br />

InStrRev Function<br />

Syntax<br />

InStrRev(S1$, S2$[, Index])<br />

Group<br />

String<br />

182


Description<br />

Return the index where S2$ last matches S1$. If no match is found return 0.<br />

Parameter Description<br />

S1$ Search for S2$ in this string value. If this value is Null then Null is returned.<br />

S2$ Search S1$ for this string value. If this value is Null then Null is returned.<br />

Index Start searching for S2$ ending at this index in S1$. If this is omitted then start<br />

searching from the end of S1$.<br />

See Also: Left$( ), Len( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print InStrRev("Hello","l") ' 4<br />

End Sub<br />

Instruction definition<br />

A single command.<br />

Beep<br />

Debug.Print "Hello"<br />

Today = Date<br />

Multiple instructions may be used instead of a single instruction by separating the single instructions with colons.<br />

X = 1:Debug.Print X<br />

If X = 1 Then Debug.Print "X=";X:Stop<br />

Beep ' must resume from Stop to get to here<br />

Int Function<br />

Syntax<br />

Int(Num)<br />

Group<br />

Math<br />

Description<br />

Return the integer value.<br />

Parameter Description<br />

Num Return the largest integer which is less than or equal to this numeric value. If this<br />

value is Null then Null is returned.<br />

Example<br />

Sub Main<br />

Debug.Print Int(9.9) ' 9<br />

Debug.Print Int(0) ' 0<br />

183


Debug.Print Int(-9.9) '-10<br />

End Sub<br />

Is Operator<br />

Syntax<br />

expr Is expr<br />

Group<br />

Operator<br />

Description<br />

Return the True if both exprs refer to the same object.<br />

See Also: Objects.<br />

Example<br />

Sub Main<br />

Dim X As Object<br />

Dim Y As Object<br />

Debug.Print X Is Y ' True<br />

End Sub<br />

IsArray Function<br />

Syntax<br />

IsArray(var)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if var is an array of values.<br />

Parameter Description<br />

var A array variable or a variant var can contain multiple of values.<br />

See Also: TypeName, VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant, Y(2) As Integer<br />

Debug.Print IsArray(X) 'False<br />

X = Array(1,4,9)<br />

Debug.Print IsArray(X) 'True<br />

184


X = Y<br />

Debug.Print IsArray(X) 'True<br />

End Sub<br />

IsDate Function<br />

Syntax<br />

IsDate(expr)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if expr is a valid date.<br />

Parameter Description<br />

expr A variant expression to test for a valid date.<br />

See Also: TypeName, VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

X = 1<br />

Debug.Print IsDate(X) 'False<br />

X = Now<br />

Debug.Print IsDate(X) 'True<br />

End Sub<br />

IsEmpty Function<br />

Syntax<br />

IsEmpty(variantvar)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if variantvar is Empty.<br />

Parameter Description<br />

variantvar A variant var is Empty if it has never been assigned a value.<br />

See Also: TypeName, VarType.<br />

Example<br />

185


Sub Main<br />

Dim X As Variant<br />

Debug.Print IsEmpty(X) 'True<br />

X = 0<br />

Debug.Print IsEmpty(X) 'False<br />

X = Empty<br />

Debug.Print IsEmpty(X) 'True<br />

End Sub<br />

IsError Function<br />

Syntax<br />

IsError(expr)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if expr is an error code.<br />

Parameter Description<br />

expr A variant expression to test for an error code value.<br />

See Also: TypeName, VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

Debug.Print IsError(X) 'False<br />

X = CVErr(1)<br />

Debug.Print IsError(X) 'True<br />

End Sub<br />

IsMissing Function<br />

Syntax<br />

IsMissing(variantvar)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if Optional parameter variantvar does not have a default value and it did not get a value. An<br />

Optional parameter may be omitted in the Sub, Function or Property call.<br />

Parameter Description<br />

186


variantvar Return True if this variant parameter's argument expression was not specified in the<br />

Sub, Function or Property call.<br />

Example<br />

Sub Main<br />

Opt 'IsMissing(A)=True<br />

Opt "Hi" 'IsMissing(A)=False<br />

Many 'No args<br />

Many 1,"Hello" 'A(0)=1 A(1)=Hello<br />

OptBye '"Bye"<br />

OptBye "No" '"No"<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Opt(Optional A)<br />

Debug.Print "IsMissing(A)=";IsMissing(A)<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Many(ParamArray A())<br />

If LBound(A) > UBound(A) Then<br />

Debug.Print "No args"<br />

Else<br />

For I = LBound(A) To UBound(A)<br />

Debug.Print "A(" & I & ")=" & A(I) & " ";<br />

Next I<br />

Debug.Print<br />

End If<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub OptBye(Optional A As String = "Bye")<br />

Debug.Print A<br />

End Sub<br />

IsNumeric Function<br />

Syntax<br />

IsNumeric(expr)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if expr is a numeric value.<br />

Parameter Description<br />

expr A variant expression is a numeric value if it is numeric or string value that represents<br />

a number.<br />

See Also: TypeName, VarType.<br />

Example<br />

187


Sub Main<br />

Dim X As Variant<br />

X = 1<br />

Debug.Print IsNumeric(X) 'True<br />

X = "1"<br />

Debug.Print IsNumeric(X) 'True<br />

X = "A"<br />

Debug.Print IsNumeric(X) 'False<br />

End Sub<br />

IsNull Function<br />

Syntax<br />

IsNull(expr)<br />

Group<br />

Variable Info<br />

Description<br />

Return the True if expr is Null.<br />

Parameter Description<br />

expr A variant expression to test for Null.<br />

See Also: TypeName, VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

Debug.Print IsEmpty(X) 'True<br />

Debug.Print IsNull(X) 'False<br />

X = 1<br />

Debug.Print IsNull(X) 'False<br />

X = "1"<br />

Debug.Print IsNull(X) 'False<br />

X = Null<br />

Debug.Print IsNull(X) 'True<br />

X = X*2<br />

Debug.Print IsNull(X) 'True<br />

End Sub<br />

IsObject Function<br />

Syntax<br />

IsObject(var)<br />

Group<br />

188


Variable Info<br />

Description<br />

Return the True if var contains an object reference.<br />

Parameter Description<br />

var A var contains an object reference if it is objexpr reference.<br />

See Also: TypeName, VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

X = 1<br />

Debug.Print IsObject(X) 'False<br />

X = "1"<br />

Debug.Print IsObject(X) 'False<br />

Set X = Nothing<br />

Debug.Print IsObject(X) 'True<br />

End Sub<br />

KeyName Function<br />

Syntax<br />

KeyName(Key)<br />

Group<br />

Miscellaneous<br />

Description<br />

Return the key name for a key number. This is the name used by SendKeys.<br />

Parameter Description<br />

Key Key number.<br />

See Also: SendKeys.<br />

Example<br />

Sub Main<br />

Debug.Print KeyName(&H270) '"^{F1}"<br />

End Sub<br />

Kill Instruction<br />

Syntax<br />

Kill Name$<br />

189


Group<br />

File<br />

Description<br />

Delete the file named by Name$.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

Example<br />

Sub Main<br />

Kill "XXX"<br />

End Sub<br />

Label definition<br />

An identifier that names a statement. Identifiers start with a letter. Following chars may be a letter, an underscore<br />

or a digit.<br />

LBound Function<br />

Syntax<br />

LBound(arrayvar[, dimension])<br />

Group<br />

Variable Info<br />

Description<br />

Return the lowest index.<br />

Parameter Description<br />

arrayvar Return the lowest index for this array variable.<br />

dimension Return the lowest index for this dimension of arrayvar. If this is omitted then return<br />

the lowest index for the first dimension.<br />

See Also: UBound( ).<br />

Example<br />

Sub Main<br />

Dim A(-1 To 3,2 To 6)<br />

Debug.Print LBound(A) '-1<br />

Debug.Print LBound(A,1) '-1<br />

Debug.Print LBound(A,2) ' 2<br />

End Sub<br />

190


LCase$ Function<br />

Syntax<br />

LCase[$](S$)<br />

Group<br />

String<br />

Description<br />

Return a string from S$ where all the uppercase letters have been lowercased.<br />

Parameter Description<br />

S$ Return the string value of this after all chars have been converted to lowercase. If<br />

this value is Null then Null is returned.<br />

See Also: StrComp( ), StrConv$( ), UCase$( ).<br />

Example<br />

Sub Main<br />

Debug.Print LCase$("Hello") '"hello"<br />

End Sub<br />

Left$ Function<br />

Syntax<br />

Left[$](S$, Len)<br />

Group<br />

String<br />

Description<br />

Return a string from S$ with only the Len chars.<br />

Note: A similar function, LeftB, returns the first Len bytes.<br />

Parameter Description<br />

S$ Return the left portion of this string value. If this value is Null then Null is returned.<br />

Len Return this many chars. If S$ is shorter than that then just return S$.<br />

See Also: InStr( ), InStrRev( ), Len( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Left$("Hello",2) '"He"<br />

End Sub<br />

191


Left$ Function<br />

Syntax<br />

Left[$](S$, Len)<br />

Group<br />

String<br />

Description<br />

Return a string from S$ with only the Len chars.<br />

Note: A similar function, LeftB, returns the first Len bytes.<br />

Parameter Description<br />

S$ Return the left portion of this string value. If this value is Null then Null is returned.<br />

Len Return this many chars. If S$ is shorter than that then just return S$.<br />

See Also: InStr( ), InStrRev( ), Len( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Left$("Hello",2) '"He"<br />

End Sub<br />

Len Function<br />

Syntax<br />

Len(S$)<br />

-or-<br />

Len(usertypevar)<br />

Group<br />

String<br />

Description<br />

Return the number of characters in S$.<br />

Note: A similar function, LenB, returns the number of bytes in the string. For a usertypevar, LenB returns the<br />

number of bytes of memory occupied by the variable's data.<br />

Parameter Description<br />

S$ Return the number of chars in this string value. If this value is Null then Null is<br />

returned.<br />

usertypevar Return the number of bytes required to store this user type variable. If the user type<br />

has any dynamic String and Variant elements the length returned may not be as big<br />

as the actual number of bytes required.<br />

See Also: InStr( ), InStrRev( ), Left$( ), Mid$( ), Replace$( ), Right$( ).<br />

192


Example<br />

Sub Main<br />

Debug.Print Len("Hello") ' 5<br />

End Sub<br />

Len Function<br />

Syntax<br />

Len(S$)<br />

-or-<br />

Len(usertypevar)<br />

Group<br />

String<br />

Description<br />

Return the number of characters in S$.<br />

Note: A similar function, LenB, returns the number of bytes in the string. For a usertypevar, LenB returns the<br />

number of bytes of memory occupied by the variable's data.<br />

Parameter Description<br />

S$ Return the number of chars in this string value. If this value is Null then Null is<br />

returned.<br />

usertypevar Return the number of bytes required to store this user type variable. If the user type<br />

has any dynamic String and Variant elements the length returned may not be as big<br />

as the actual number of bytes required.<br />

See Also: InStr( ), InStrRev( ), Left$( ), Mid$( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Len("Hello") ' 5<br />

End Sub<br />

Let Instruction<br />

Syntax<br />

[Let] var = expr<br />

Group<br />

Assignment<br />

Description<br />

193


Assign the value of expr to var. The keyword Let is optional.<br />

Example<br />

Sub Main<br />

Let X = 1<br />

X = X*2<br />

Debug.Print X ' 2<br />

End Sub<br />

Like Operator<br />

Syntax<br />

str1 Like str2<br />

Group<br />

Operator<br />

Description<br />

Return the True if str1 matches pattern str2. The pattern in str2 is one or more of the special character sequences<br />

shown in the following table.<br />

Char(s) Description<br />

? Match any single character<br />

* Match zero or more characters<br />

# Match a single digit (0-9)<br />

[charlist] Match any char in the list<br />

[!charlist] Match any char not in the list<br />

Example<br />

Sub Main<br />

Debug.Print "abcdfgcdefg" Like "" ' False<br />

Debug.Print "abcdfgcdefg" Like "a*g" ' True<br />

Debug.Print "abcdfgcdefg" Like "a*cde*g" ' True<br />

Debug.Print "abcdfgcdefg" Like "a*cd*cd*g" ' True<br />

Debug.Print "abcdfgcdefg" Like "a*cd*cd*g" ' True<br />

Debug.Print "00aa" Like "####" ' False<br />

Debug.Print "00aa" Like "????" ' True<br />

Debug.Print "00aa" Like "##??" ' True<br />

Debug.Print "00aa" Like "*##*" ' True<br />

Debug.Print "hk" Like "hk*" ' True<br />

End Sub<br />

Line Input Instruction<br />

Syntax<br />

Line Input [#]StreamNum, S$<br />

194


Group<br />

File<br />

Description<br />

Get a line of input from StreamNum and assign it to S$.<br />

See Also: Input, Print, Write.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

Line Input #1,S$<br />

Debug.Print S$<br />

Close #1<br />

End Sub<br />

Line Input Instruction<br />

Syntax<br />

Line Input [#]StreamNum, S$<br />

Group<br />

File<br />

Description<br />

Get a line of input from StreamNum and assign it to S$.<br />

See Also: Input, Print, Write.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

Line Input #1,S$<br />

Debug.Print S$<br />

Close #1<br />

End Sub<br />

ListBox Dialog Item Definition<br />

Syntax<br />

ListBox X, Y, DX, DY, StrArray$( ), .Field[, Options]<br />

Group<br />

195


User Dialog<br />

Description<br />

Define a listbox item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the non-null<br />

elements of the array are used.<br />

Field The value of the list box is accessed via this field. It is the index of the StrArray$( )<br />

var.<br />

Options This numeric value controls the type of list box. Choose one value from following<br />

table. (If this numeric value omitted then zero is used.)<br />

Parameter Description<br />

0 List is not sorted.<br />

2 List is sorted.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Dim lists$(3)<br />

lists$(0) = "List 0"<br />

lists$(1) = "List 1"<br />

lists$(2) = "List 2"<br />

lists$(3) = "List 3"<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

ListBox 10,25,180,60,lists$(),.list<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.list = 2<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.list<br />

End Sub<br />

Little-endian definition<br />

Multiple byte data values (not strings) are stored with the lowest order byte first. For example, the long integer<br />

&H01020304 is stored as this sequence of four bytes: &H04, &H03, &H02 and &H01. A Binary or Random file<br />

written using Put uses little-endian format so that it can be read using Get on any machine. (Big-endian machines,<br />

like the Power-PC, reverse the bytes as they are read by Get or written by Put.)<br />

196


Loc Function<br />

Syntax<br />

Loc(StreamNum)<br />

Group<br />

File<br />

Description<br />

Return StreamNum file position. For Random mode files this is the current record number minus one. For Binary<br />

mode files it is the current byte position minus one. Otherwise, it is the current byte position minus one divided by<br />

128. The first position in the file is 0.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

L = Loc(1)<br />

Close #1<br />

Debug.Print L ' 0<br />

End Sub<br />

Lock Instruction<br />

Syntax<br />

Lock StreamNum<br />

-or-<br />

Lock StreamNum, RecordNum<br />

-or-<br />

Lock StreamNum, [start] To end<br />

Group<br />

File<br />

Description<br />

Form 1: Lock all of StreamNum.<br />

Form 2: Lock a record (or byte) of StreamNum.<br />

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

(or byte).<br />

Note: Be sure to Unlock for each Lock instruction.<br />

Note: For sequential files (Input, Output and Append) lock always affects the entire file.<br />

Parameter Description<br />

197


StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

RecordNum For Random mode files this is the record number. The first record is 1. Otherwise, it<br />

is the byte position. The first byte is 1.<br />

start First record (or byte) in the range.<br />

end Last record (or byte) in the range.<br />

See Also: Open, Unlock.<br />

Example<br />

Sub Main<br />

Dim V As Variant<br />

Open "SAVE_V.DAT" For Binary As #1<br />

Lock #1<br />

Get #1, 1, V<br />

V = "Hello"<br />

Put #1, 1, V<br />

Unlock #1<br />

Close #1<br />

End Sub<br />

LOF Function<br />

Syntax<br />

LOF(StreamNum)<br />

Group<br />

File<br />

Description<br />

Return StreamNum file length (in bytes).<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

L = LOF(1)<br />

Close #1<br />

Debug.Print L<br />

End Sub<br />

Log Function<br />

Syntax<br />

198


Log(Num)<br />

Group<br />

Math<br />

Description<br />

Return the natural logarithm.<br />

Parameter Description<br />

Num Return the natural logarithm of this numeric value. The value e is approximately<br />

2.718282.<br />

Example<br />

Sub Main<br />

Debug.Print Log(1) ' 0<br />

End Sub<br />

LSet Instruction<br />

Syntax<br />

LSet strvar = str<br />

-or-<br />

LSet usertypevar1 = usertypevar2<br />

Group<br />

Assignment<br />

Description<br />

Form 1: Assign the value of str to strvar. Shorten str by removing trailing chars (or extend with blanks). The<br />

previous length strvar is maintained.<br />

Form 2: Assign the value of usertypevar2 to usertypevar1. If usertypevar2 is longer than usertypevar1 then only<br />

copy as much as usertypevar1 can handle.<br />

See Also: RSet.<br />

Example<br />

Sub Main<br />

S$ = "123"<br />

LSet S$ = "A"<br />

Debug.Print ".";S$;"." '".A ."<br />

End Sub<br />

199


LTrim$ Function<br />

Syntax<br />

LTrim[$](S$)<br />

Group<br />

String<br />

Description<br />

Return the string with S$'s leading spaces removed.<br />

Parameter Description<br />

S$ Copy this string without the leading spaces. If this value is Null then Null is returned.<br />

See Also: RTrim$( ), Trim$( ).<br />

Example<br />

Sub Main<br />

Debug.Print ".";LTrim$(" x ");"." '".x ."<br />

End Sub<br />

Macro definition<br />

A macro is like an application. Execution starts at the macro's Sub Main.<br />

MacroDir$ Function<br />

Syntax<br />

MacroDir[$]<br />

Group<br />

Flow Control<br />

Description<br />

Return the directory of the current macro. A run-time error occurs if the current macro has never been saved.<br />

See Also: MacroRun.<br />

Example<br />

Sub Main<br />

' open the file called Data that is in the<br />

' same directory as the macro<br />

Open MacroDir & "\Data" For Input As #1<br />

Line Input #1, S$<br />

200


Debug.Print S$<br />

Close #1<br />

End Sub<br />

MacroRun Instruction<br />

Syntax<br />

MacroRun MacroName$[, Command$]<br />

Group<br />

Flow Control<br />

Description<br />

Play a macro. Execution will continue at the following statement after the macro has completed.<br />

Parameter Description<br />

MacroName$ Run the macro named by this string value.<br />

Command$ Pass this string value as the macro's Command$ value.<br />

See Also: Command$, MacroDir$, MacroRunThis.<br />

Example<br />

Sub Main<br />

Debug.Print "Before Demo"<br />

MacroRun "Demo"<br />

Debug.Print "After Demo"<br />

End Sub<br />

MacroRunThis Instruction<br />

Syntax<br />

MacroRunThis MacroCode$<br />

Group<br />

Flow Control<br />

Description<br />

Play the macro code. Execution will continue at the following statement after the macro code has completed. The<br />

macro code can be either a single line or a complete macro.<br />

Parameter Description<br />

MacroName$ Run the macro named by this string value.<br />

See Also: Command$, MacroDir$, MacroRun.<br />

Example<br />

201


Sub Main<br />

Debug.Print "Before Demo"<br />

MacroRunThis "MsgBox ""Hello"""<br />

Debug.Print "After Demo"<br />

End Sub<br />

Me Object<br />

Syntax<br />

Me<br />

Group<br />

Object<br />

Description<br />

Me references the current macro/module. It can be used like any other object variable, except that it's reference<br />

can't be changed.<br />

See Also: Set.<br />

Example<br />

Sub Main<br />

DoIt<br />

Me.DoIt ' calls the same sub<br />

End Sub<br />

Sub DoIt<br />

MsgBox "Hello"<br />

End Sub<br />

Method definition<br />

An object provides methods and properties. Methods can be called as subs (the return value is ignored), or used<br />

as functions (the return value is used).<br />

If the method name contains characters that are not legal in a name, surround the method name with [].<br />

App.[Title$]<br />

Mid$ Function/Assignment<br />

Syntax<br />

Mid[$](S$, Index[, Len])<br />

-or-<br />

202


Mid[$](strvar, Index[, Len]) = S$<br />

Group<br />

String<br />

Description<br />

Function: Return the substring of S$ starting at Index for Len chars.<br />

Instruction: Assign S$ to the substring in strvar starting at Index for Len chars.<br />

Note: A similar function, MidB, returns the Len bytes starting a byte Index.<br />

Parameter Description (Mid Function)<br />

S$ Copy chars from this string value. If this value is Null then Null is returned.<br />

Index Start copying chars starting at this index value. If the string is not that long then<br />

return a null string.<br />

Len Copy this many chars. If the S$ does not have that many chars starting at Index then<br />

copy the remainder of S$.<br />

Parameter Description (Mid Assignment)<br />

strvar Change part of this string.<br />

Index Change strvar starting at this index value. If the string is not that long then it is not<br />

changed.<br />

Len The number of chars copied is smallest of: the value of Len, the length of S$ and the<br />

remaining length of strvar. (If this value is omitted then the number of chars copied<br />

is the smallest of: the length of S$ and the remaining length of strvar.)<br />

S$ Copy chars from this string value.<br />

See Also: InStr( ), Left$( ), Len( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

S$ = "Hello There"<br />

Mid$(S$,7) = "?????????"<br />

Debug.Print S$ '"Hello ?????"<br />

Debug.Print Mid$("Hello",2,1) '"e"<br />

End Sub<br />

Mid$ Function/Assignment<br />

Syntax<br />

Mid[$](S$, Index[, Len])<br />

-or-<br />

Mid[$](strvar, Index[, Len]) = S$<br />

Group<br />

String<br />

Description<br />

Function: Return the substring of S$ starting at Index for Len chars.<br />

203


Instruction: Assign S$ to the substring in strvar starting at Index for Len chars.<br />

Note: A similar function, MidB, returns the Len bytes starting a byte Index.<br />

Parameter Description (Mid Function)<br />

S$ Copy chars from this string value. If this value is Null then Null is returned.<br />

Index Start copying chars starting at this index value. If the string is not that long then<br />

return a null string.<br />

Len Copy this many chars. If the S$ does not have that many chars starting at Index then<br />

copy the remainder of S$.<br />

Parameter Description (Mid Assignment)<br />

strvar Change part of this string.<br />

Index Change strvar starting at this index value. If the string is not that long then it is not<br />

changed.<br />

Len The number of chars copied is smallest of: the value of Len, the length of S$ and the<br />

remaining length of strvar. (If this value is omitted then the number of chars copied<br />

is the smallest of: the length of S$ and the remaining length of strvar.)<br />

S$ Copy chars from this string value.<br />

See Also: InStr( ), Left$( ), Len( ), Replace$( ), Right$( ).<br />

Example<br />

Sub Main<br />

S$ = "Hello There"<br />

Mid$(S$,7) = "?????????"<br />

Debug.Print S$ '"Hello ?????"<br />

Debug.Print Mid$("Hello",2,1) '"e"<br />

End Sub<br />

Minute Function<br />

Syntax<br />

Minute(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the minute of the hour (0 to 59).<br />

Parameter Description<br />

dateexpr Return the minute of the hour for this date value. If this value is Null then Null is<br />

returned.<br />

See Also: Hour( ), Second( ), Time( ).<br />

Example<br />

Sub Main<br />

Debug.Print Minute(#12:00:01 AM#) ' 0<br />

End Sub<br />

204


MkDir Instruction<br />

Syntax<br />

MkDir Name$<br />

Group<br />

File<br />

Description<br />

Make directory Name$.<br />

Parameter Description<br />

Name$ This string value is the path and name of the directory. A path relative to the current<br />

directory can be used.<br />

See Also: RmDir.<br />

Example<br />

Sub Main<br />

MkDir "C:\WWTEMP"<br />

End Sub<br />

Module definition<br />

A file with public symbols that are accessible by other modules/macros via the #Uses comment.<br />

A module is loaded on demand.<br />

A code module is a code library.<br />

An object module or class module implements an ActiveX Automation object.<br />

A module may also access other modules with its own #Uses comments.<br />

Month Function<br />

Syntax<br />

Month(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the month of the year (1 to 12).<br />

205


Parameter Description<br />

dateexpr Return the month of the year for this date value. If this value is Null then Null is<br />

returned.<br />

See Also: Date( ), Day( ), MonthName( ), Weekday( ), Year( ).<br />

Example<br />

Sub Main<br />

Debug.Print Month(#1/1/1900#) ' 1<br />

Debug.Print Month(#2/1/1900#) ' 2<br />

End Sub<br />

MonthName Function<br />

Syntax<br />

MonthName(NumZ{month}[, CondZ{abbrev}])<br />

Group<br />

Time/Date<br />

Description<br />

Return the localized name of the month.<br />

Parameter Description<br />

month Return the localized name of this month. (1-12)<br />

abbrev If this conditional value is True then return the abbreviated form of the month name.<br />

See Also: Month( ).<br />

Example<br />

Sub Main<br />

Debug.Print MonthName(1) 'January<br />

Debug.Print MonthName(Month(Now))<br />

End Sub<br />

MsgBox Instruction/Function<br />

Syntax<br />

MsgBox Message$[, Type][, Title$]<br />

-or-<br />

MsgBox(Message$[, Type][, Title$])<br />

Group<br />

User Input<br />

206


Description<br />

Show a message box titled Title$. Type controls what the message box looks like (choose one value from each<br />

category). Use MsgBox( ) if you need to know what button was pressed. The result indicates which button was<br />

pressed.<br />

Result Value Button Pressed<br />

vbOK 1 OK button<br />

vbCancel 2 Cancel button<br />

vbAbort 3 Abort button<br />

vbRetry 4 Retry button<br />

vbIgnore 5 Ignore button<br />

vbYes 6 Yes button<br />

vbNo 7 No button<br />

Parameter Description<br />

Message$ This string value is the text that is shown in the message box.<br />

Type This numeric value controls the type of message box. Choose one value from each of<br />

the following tables.<br />

Title$ This string value is the title of the message box.<br />

Button Value Effect<br />

vbOkOnly 0 OK button<br />

vbOkCancel 1 OK and Cancel buttons<br />

vbAbortRetryIgnore 2 Abort, Retry, Ignore buttons<br />

vbYesNoCancel 3 Yes, No, Cancel buttons<br />

vbYesNo 4 Yes and No buttons<br />

vbRetryCancel 5 Retry and Cancel buttons<br />

Icon Value Effect<br />

0 No icon<br />

vbCritical 16 Stop icon<br />

vbQuestion 32 Question icon<br />

vbExclamation 48 Attention icon<br />

vbInformation 64 Information icon<br />

Default Value Effect<br />

vbDefaultButton1 0 First button<br />

vbDefaultButton2 256 Second button<br />

vbDefaultButton3 512 Third button<br />

Mode Value Effect<br />

vbApplicationModal 0 Application modal<br />

vb<strong>System</strong>Modal 1000 <strong>System</strong> modal<br />

Example<br />

Sub Main<br />

MsgBox "Please press OK button"<br />

If MsgBox("Please press OK button",vbOkCancel) = vbOK Then<br />

Debug.Print "OK was pressed"<br />

Else<br />

Debug.Print "Cancel was pressed"<br />

End If<br />

End Sub<br />

207


MultiListBox Dialog Item Definition<br />

Syntax<br />

MultiListBox X, Y, DX, DY, StrArray$( ), .Field[, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a multiple selection listbox item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the non-null<br />

elements of the array are used.<br />

Field The value of the list box is accessed via this field. It is the index of the StrArray$( )<br />

var.<br />

Options This numeric value controls the type of list box. Choose one value from following<br />

table. (If this numeric value omitted then zero is used.)<br />

Parameter Description<br />

0 List is not sorted.<br />

1 List is not sorted and horizontally scrollable.<br />

2 List is sorted.<br />

3 List is sorted and horizontally scrollable.<br />

See Also: Begin Dialog, Dim As UserDialog, ListBox.<br />

Example<br />

Sub Main<br />

Dim lists$(3)<br />

lists$(0) = "List 0"<br />

lists$(1) = "List 1"<br />

lists$(2) = "List 2"<br />

lists$(3) = "List 3"<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

MultiListBox 10,25,180,60,lists$(),.list<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.list = Array (2)<br />

Dialog dlg ' show dialog (wait for ok)<br />

For i = LBound(dlg.list) To UBound(dlg.list)<br />

Debug.Print lists$(dlg.list(i));<br />

Next i<br />

Debug.Print<br />

End Sub<br />

208


Name definition<br />

An identifier that names a variable or a user defined procedure. Identifiers start with a letter. Following chars may<br />

be a letter, an underscore or a digit.<br />

Count<br />

DaysTill2000<br />

Get_Data<br />

Name Instruction<br />

Syntax<br />

Name OldName$ As NewName$<br />

Group<br />

File<br />

Description<br />

Rename file OldName$ as NewName$.<br />

Parameter Description<br />

OldName$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

NewName$ This is the new file name (and path). A path relative to the current directory can be<br />

used.<br />

Example<br />

Sub Main<br />

Name "AUTOEXEC.BAK" As "AUTOEXEC.SAV"<br />

End Sub<br />

Now Function<br />

Syntax<br />

Now<br />

Group<br />

Time/Date<br />

Description<br />

Return the current date and time as a date value.<br />

209


See Also: Date, Time, Timer.<br />

Example<br />

Sub Main<br />

Debug.Print Now ' example: 1/1/1995 10:05:32 AM<br />

End Sub<br />

Num definition<br />

An expression that returns a numeric result. Use &O to express an octal number. Use &H to express a hex number.<br />

Numvar definition<br />

A variable that holds one numeric value. The name of a numeric variable may be followed by the appropriate type<br />

char.<br />

Objexpr definition<br />

A expression that returns a reference to an object or module.<br />

CreateObject("WinWrap.CDemoApplication")<br />

Objtype definition<br />

A specific ActiveX Automation type defined by your application, another application or by an object module or class<br />

module.<br />

See Also: Objects, CreateObject( ), GetObject( ).<br />

Objvar definition<br />

A variable that holds a objexpr which references an object. Object variables are declared using As Object in a Dim,<br />

Private or Public statement.<br />

See Also: Objects.<br />

210


Oct$ Function<br />

Syntax<br />

Oct[$](Num)<br />

Group<br />

String<br />

Description<br />

Return a octal string.<br />

Parameter Description<br />

Num Return an octal encoded string for this numeric value.<br />

See Also: Hex$( ), Str$( ), Val( ).<br />

Example<br />

Sub Main<br />

Debug.Print Oct$(15) '17<br />

End Sub<br />

OKButton Dialog Item Definition<br />

Syntax<br />

OKButton X, Y, DX, DY[, .Field]<br />

Group<br />

User Dialog<br />

Description<br />

Define an OK button item. Pressing the OK button updates the dlgvar field values and closes the dialog. (Dialog( )<br />

function call returns -1.)<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this is omitted then the field name is "OK".<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

211


Begin Dialog UserDialog 200,120<br />

Text 10,10,180,30,"Please push the OK button"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

On Error Instruction<br />

Syntax<br />

On Error GoTo 0<br />

-or-<br />

On Error GoTo label<br />

-or-<br />

On Error Resume Next<br />

Group<br />

Error Handling<br />

Description<br />

Form 1: Disable the error handler (default).<br />

Form 2: Send error conditions to an error handler.<br />

Form 3: Error conditions continue execution at the next statement.<br />

On Error sets or disables the error handler. Each user defined procedure has its own error handler. The default is<br />

to terminate the macro on any error. The Err object's properties are set whenever an error occurs. Once an error<br />

has occurred and the error handler is executing any further errors will terminate the macro, unless the Err object<br />

has been cleared.<br />

Note: This instruction clears the Err and sets Error$ to null.<br />

Example<br />

Sub Main<br />

On Error Resume Next<br />

Err.Raise 1<br />

Debug.Print "RESUMING, Err=";Err<br />

On Error GoTo X<br />

Err.Raise 1<br />

Exit Sub<br />

X: Debug.Print "Err=";Err<br />

Err.Clear<br />

Debug.Print "Err=";Err<br />

Resume Next<br />

End Sub<br />

212


Open Instruction<br />

Syntax<br />

Open Name$ For mode [Access access] [lock] As _<br />

[#]StreamNum [Len = RecordLen]<br />

Group<br />

File<br />

Description<br />

Open file Name$ for mode as StreamNum.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

mode May be Input, Output, Append, Binary or Random.<br />

access May be Read, Write or Read Write.<br />

lock May be Shared, Lock Read, Lock Write or Lock Read Write.<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

RecordLen This numeric value is the record length for Random mode files. Other file modes<br />

ignore this value.<br />

See Also: Close, FileAttr, FreeFile, Reset.<br />

Example<br />

Sub Main<br />

Open "XXX" For Output As #1<br />

Print #1,"1,2,""Hello"""<br />

Close #1<br />

End Sub<br />

Option Definition<br />

Syntax<br />

Option Base [0|1]<br />

-or-<br />

Option Explicit<br />

-or-<br />

Option Private Module<br />

Group<br />

Declaration<br />

Description<br />

Form 1: Set the default base index for array declarations. Affects Dim, Static, Private, Public and ReDim. Does not<br />

affect Array, ParamArray or arrays declare in a Type. Option Base 0 is the default.<br />

213


Form 2: Require all variables to be declared prior to use. Variables are declared using Dim, Private, Public, Static<br />

or as a parameter of Sub, Function or Property blocks.<br />

Form 3: Public symbols defined by the module are only accessible from the same project.<br />

See Also: Dim, Private, Public, ReDim, Static.<br />

Example<br />

Option Base 1<br />

Option Explicit<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Dim A<br />

Dim C(2) ' same as Dim C(1 To 2)<br />

Dim D(0 To 2)<br />

A = 1<br />

B = 2 ' B has not been declared<br />

End Sub<br />

OptionButton Dialog Item Definition<br />

Syntax<br />

OptionButton X, Y, DX, DY, Title$[, .Field]<br />

Group<br />

User Dialog<br />

Description<br />

Define an option button item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ The value of this string is the title of the option button.<br />

See Also: Begin Dialog, Dim As UserDialog, OptionGroup.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OptionGroup .options<br />

OptionButton 10,30,180,15,"Option &0"<br />

OptionButton 10,45,180,15,"Option &1"<br />

OptionButton 10,60,180,15,"Option &2"<br />

214


OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.options = 2<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.options<br />

End Sub<br />

OptionGroup Dialog Item Definition<br />

Syntax<br />

OptionGroup .Field<br />

OptionButton X, Y, DX, DY, Title$[, .Field]<br />

OptionButton X, Y, DX, DY, Title$[, .Field]<br />

...<br />

Group<br />

User Dialog<br />

Description<br />

Define a optiongroup and option button items.<br />

Parameter Description<br />

Field The value of the option group is accessed via this field. This first option button is 0,<br />

the second is 1, etc.<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ The value of this string is the title of the option button.<br />

See Also: Begin Dialog, Dim As UserDialog, OptionButton.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OptionGroup .options<br />

OptionButton 10,30,180,15,"Option &0"<br />

OptionButton 10,45,180,15,"Option &1"<br />

OptionButton 10,60,180,15,"Option &2"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.options = 2<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.options<br />

End Sub<br />

215


Param definition<br />

[ [Optional] [ | ByVal | ByRef ] | ParamArray ] param[type][( )] [As type] [ = defaultvalue ]<br />

The param receives the value of the associated expression in the Declare, Sub, Function or Property call. (See<br />

arglist.)<br />

An Optional param may be omitted from the call. It may also have a defaultvalue. The parameter receives the<br />

default value if a value is not specified by the call. If the default value is omitted, the parameter is a Variant<br />

and no value is specified in the call then IsMissing will return True.<br />

All parameters following an Optional parameter must also be Optional.<br />

ParamArray may be used on the final param. It must be an array of Variant type. It must not follow any Optional<br />

parameters. The ParamArray receives all the expressions at the end of the call as an array. If<br />

LBound(param) > UBound(param) then the ParamArray didn't receive any expressions.<br />

If the param is not ByVal and the expression is merely a variable then the param is a reference to that variable<br />

(ByRef). (Changing param changes the variable.) Otherwise, the parameter variable is local to the<br />

procedure, so changing its value does not affect the caller.<br />

Use param( ) to specify an array parameter. An array parameter must be referenced and can not be passed by<br />

value. The bounds of the parameter array are available via LBound( ) and UBound( ).<br />

Picture Dialog Item Definition<br />

Syntax<br />

Picture X, Y, DX, DY, FileName$, Type[, .Field]<br />

Group<br />

User Dialog<br />

Description<br />

Define a picture item. The bitmap is automatically sized to fit the item's entire area.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

FileName$ The value of this string is the .BMP file shown in the picture control.<br />

Type This numeric value indicates the type of bitmap used. See below.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this identifer is omitted then the first two words of the title are used.<br />

Type Effect<br />

216


0 FileName is the name of the bitmap file. If the file does not exist then "(missing picture)" is<br />

displayed.<br />

3 The clipboard's bitmap is displayed. Not supported.<br />

+16 Instead of displaying "(missing picture)" a run-time error occurs.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Picture 10,10,180,75,"SAMPLE.BMP",0<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

Precedence definition<br />

When several operators are used in an expression, each operator is evaluated in a predetermined order. Operators<br />

are evaluated in this order:<br />

^ (power)<br />

- (negate)<br />

* (multiply), / (divide)<br />

\ (integer divide)<br />

Mod (integer remainder)<br />

+ (add), - (difference)<br />

& (string concatenate)<br />

= (equal), (not equal), < (less than) > (greater than), = (greater than or equal<br />

to), Like, (string similarity) Is (object equivalence)<br />

Not (logical bitwise invert)<br />

And (logical bitwise and)<br />

Or (logical or bitwise or)<br />

Xor (logical or bitwise exclusive-or)<br />

Eqv (logical or bitwise equivalence)<br />

Imp (logical or bitwise implication)<br />

Operators shown on the same line are evaluated from left to right.<br />

Print Instruction<br />

Syntax<br />

217


Print #StreamNum, [expr[; ...][;]]<br />

Group<br />

File<br />

Description<br />

Print the expr(s) to StreamNum. Use ; to separate expressions. A num is it automatically converted to a string<br />

before printing (just like Str$( )). If the instruction does not end with a semicolon, then a new line is printed at the<br />

end.<br />

See Also: Input, Line Input, Write.<br />

Example<br />

Sub Main<br />

A = 1<br />

B = 2<br />

C$ = "Hello"<br />

Open "XXX" For Output As #1<br />

Print #1,A;",";B;",""";C$;""""<br />

Close #1<br />

End Sub<br />

Private Definition<br />

Syntax<br />

Private [WithEvents] name[type][([dim[, ...]])] [As [New] type][, ...]<br />

Group<br />

Declaration<br />

Description<br />

Create arrays (or simple variables) which are available to the entire macro/module, but not other macros/modules.<br />

Dimension var array(s) using the dims to establish the minimum and maximum index value for each dimension. If<br />

the dims are omitted then a scalar (single value) variable is defined. A dynamic array is declared using ( ) without<br />

any dims. It must be ReDimensioned before it can be used. The Private statement must be placed outside of Sub,<br />

Function or Property blocks.<br />

See Also: Dim, Option Base, Public, ReDim, Static, WithEvents.<br />

Example<br />

Private A0,A1(1),A2(1,1)<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Init<br />

A0 = 1<br />

A1(0) = 2<br />

A2(0,0) = 3<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

218


Sub Main<br />

Init<br />

Debug.Print A0;A1(0);A2(0,0) ' 1 2 3<br />

End Sub<br />

Procedure definition<br />

A subroutine, function or property.<br />

Property definition<br />

An object provides methods and properties. Properties may be used as values (like a function call) or changed<br />

(using assignment syntax).<br />

If the property name contains characters that are not legal in a name, surround the property name with [].<br />

App.[Title$]<br />

See Also: Objects.<br />

Property Definition<br />

Syntax<br />

[ | Private | Public | Friend ] _<br />

Property Get name[type][([param[, ...]])] [As type[()]]<br />

statements<br />

End Property<br />

-or-<br />

[ | Private | Public | Friend ] _<br />

Property [Let|Set] name[([param[, ...]])]<br />

statements<br />

End Property<br />

Group<br />

Declaration<br />

Description<br />

User defined property. The property defines a set of statements to be executed when its value is used or changed.<br />

A property acts like a variable, except that getting its value calls Property Get and changing its value calls Property<br />

Let (or Property Set). Property Get and Property Let with the same name define a property that holds a value.<br />

Property Get and Property Set with the same name define a property that holds an object reference. The values of<br />

the calling arglist are assigned to the params. (For Property Let and Property Set the last parameter is the value<br />

on the right hand side of the assignment operator.)<br />

Property defaults to Public if Private, Public or Friend are not is specified.<br />

219


See Also: Function, Sub.<br />

Example<br />

Dim X_Value<br />

Property Get X()<br />

X = X_Value<br />

End Property<br />

Property Let X(NewValue)<br />

If Not IsNull(NewValue) Then X_Value = NewValue<br />

End Property<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

X = "Hello"<br />

Debug.Print X<br />

X = Null<br />

Debug.Print X<br />

End Sub<br />

Public Definition<br />

Syntax<br />

Public [WithEvents] name[type][([dim[, ...]])] [As [New] type][, ...]<br />

Group<br />

Declaration<br />

Description<br />

Create arrays (or simple variables) which are available to the entire macro/module and other macros/modules.<br />

Dimension var array(s) using the dims to establish the minimum and maximum index value for each dimension. If<br />

the dims are omitted then a scalar (single value) variable is defined. A dynamic array is declared using ( ) without<br />

any dims. It must be ReDimensioned before it can be used. The Public statement must be placed outside of Sub,<br />

Function or Property blocks.<br />

See Also: Dim, Option Base, Private, ReDim, Static, WithEvents.<br />

Example<br />

Public A0,A1(1),A2(1,1)<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Init<br />

A0 = 1<br />

A1(0) = 2<br />

A2(0,0) = 3<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Init<br />

Debug.Print A0;A1(0);A2(0,0) ' 1 2 3<br />

End Sub<br />

220


PushButton Dialog Item Definition<br />

Syntax<br />

PushButton X, Y, DX, DY, Title$[, .Field]<br />

Group<br />

User Dialog<br />

Description<br />

Define a push button item. Pressing the push button updates the dlgvar field values and closes the dialog.<br />

(Dialog( ) function call returns the push button's ordinal number in the dialog. The first push button returns 1.)<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ The value of this string is the title of the push button control.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this identifer is omitted then the first two words of the title are used.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,30,"Please push the DoIt button"<br />

OKButton 40,90,40,20<br />

PushButton 110,90,60,20,"&Do It"<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Debug.Print Dialog(dlg)<br />

End Sub<br />

Put Instruction<br />

Syntax<br />

Put StreamNum, [RecordNum], var<br />

Group<br />

File<br />

221


Description<br />

Write a variable's value to StreamNum.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

RecordNum For Random mode files this is the record number. The first record is 1. Otherwise, it<br />

is the byte position. The first byte is 1. If this is omitted then the current position (or<br />

record number) is used.<br />

var This variable value is written to the file. For a fixed length variable (like Long) the<br />

number of bytes required to store the variable are written. For a Variant variable two<br />

bytes which describe its type are written and then the variable value is written<br />

accordingly. For a usertype variable each field is written in sequence. For an array<br />

variable each element is written in sequence. For a dynamic array variable the<br />

number of dimensions and range of each dimension is written prior to writing the<br />

array values. All binary data values are written to the file in little-endian format.<br />

See Also: Get, Open.<br />

Example<br />

222<br />

Note: When a writing string (or a dynamic array) to a Binary mode file the string<br />

length (or array dimension) information is not written. Only the string data or array<br />

elements are written.<br />

Sub Main<br />

Dim V As Variant<br />

Open "SAVE_V.DAT" For Binary Access Write As #1<br />

Put #1, , V<br />

Close #1<br />

End Sub<br />

QBColor Function<br />

Syntax<br />

QBColor(num)<br />

Group<br />

Miscellaneous<br />

Description<br />

Return the appropriate color defined by Quick Basic.<br />

num color<br />

0 black<br />

1 blue<br />

2 green<br />

3 cyan<br />

4 red<br />

5 magenta<br />

6 yellow<br />

7 white<br />

8 gray


9 light blue<br />

10 light green<br />

11 light cyan<br />

12 light red<br />

13 light magenta<br />

14 light yellow<br />

15 bright white<br />

See Also: RGB( ).<br />

Example<br />

Sub Main<br />

Debug.Print Hex(QBColor(1)) '"800000"<br />

Debug.Print Hex(QBColor(7)) '"C0C0C0"<br />

Debug.Print Hex(QBColor(8)) '"808080"<br />

Debug.Print Hex(QBColor(9)) '"FF0000"<br />

Debug.Print Hex(QBColor(10)) '"FF00"<br />

Debug.Print Hex(QBColor(12)) '"FF"<br />

Debug.Print Hex(QBColor(15)) '"FFFFFF"<br />

End Sub<br />

Randomize Instruction<br />

Syntax<br />

Randomize [Seed]<br />

Group<br />

Math<br />

Description<br />

Randomize the random number generator.<br />

Parameter Description<br />

Seed This numeric value sets the initial seed for the random number generator. If this<br />

value is omitted then the current time is used as the seed.<br />

See Also: Rnd( ).<br />

Example<br />

Sub Main<br />

Randomize<br />

Debug.Print Rnd ' 0.??????????????<br />

End Sub<br />

ReDim Instruction<br />

Syntax<br />

223


ReDim [Preserve] name[type][([dim[, ...]])] [As type][, ...]<br />

-or-<br />

ReDim [Preserve] usertypevar.elem[type][([dim[, ...]])] [As type][, ...]<br />

Group<br />

Declaration<br />

Description<br />

Redimension a dynamic arrayvar or user defined type array element. Use Preserve to keep the array values.<br />

Otherwise, the array values will all be reset. When using preserve only the last index of the array may change, but<br />

the number of indexes may not. (A one-dimensional array can't be redimensioned as a two-dimensional array.)<br />

See Also: Dim, Option Base, Private, Public, Static.<br />

Example<br />

Sub Main<br />

Dim X()<br />

ReDim X(3)<br />

Debug.Print UBound(X) ' 3<br />

ReDim X(200)<br />

Debug.Print UBound(X) ' 200<br />

End Sub<br />

Reference Comment<br />

Syntax<br />

'#Reference {uuid}#vermajor.verminor#lcid#[path[#name]]<br />

Description<br />

The Reference comment indicates that the current macro/module references the type library identified. Reference<br />

comment lines must be the first lines in the macro/module (following the global Attributes). Reference comments<br />

are in reverse priority (from lowest to highest). The IDE does not display the reference comments.<br />

Parameter Description<br />

uuid Type library's universally unique identifier.<br />

vermajor Type library's major version number.<br />

verminor Type library's minor version number.<br />

lcid Type library's locale identifier.<br />

path Type library's path.<br />

name Type library's name.<br />

Example<br />

'#Reference {00025E01-0000-0000-C000-000000000046}#4.0#0#C:\PROGRAM FILES\COMMON<br />

FILES\MICROSOFT SHARED\DAO\DAO350.DLL#Microsoft DAO 3.5 Object Library<br />

224


Rem Instruction<br />

Syntax<br />

Rem ...<br />

-or-<br />

'...<br />

Group<br />

Miscellaneous<br />

Description<br />

Both forms are comments. The Rem form is an instruction. The ' form can be used at the end of any line. All text<br />

from either ' or Rem to the end of the line is part of the comment. That text is not executed.<br />

Example<br />

Sub Main<br />

Debug.Print "Hello" ' prints to the output window<br />

Rem the macro terminates at Main's End Sub<br />

End Sub<br />

Replace$ Function<br />

Syntax<br />

Replace[$](S$, Pat$, Rep$, [Index], [Count])<br />

Group<br />

String<br />

Description<br />

Replace Pat$ with Rep$ in S$.<br />

Parameter Description<br />

S$ This string value is searched. Replacements are made in the string returned by<br />

Replace.<br />

Pat$ This string value is the pattern to look for.<br />

Rep$ This string value is the replacement.<br />

Index This numeric value is the starting index in S$. Replace(S,Pat,Rep,N) is equivalent to<br />

Replace(Mid(S,N),Pat,Rep). If this is omitted use 1.<br />

Count This numeric value is the maximum number of replacements that will be done. If this<br />

is omitted use -1 (which means replace all occurrences).<br />

See Also: InStr( ), InStrRev( ), Left$( ), Len( ), Mid$( ), Right$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Replace$("abcabc","b","B") '"aBcaBc"<br />

Debug.Print Replace$("abcabc","b","B",,1) '"aBcabc"<br />

Debug.Print Replace$("abcabc","b","B",3) '"caBc"<br />

225


Debug.Print Replace$("abcabc","b","B",9) '""<br />

End Sub<br />

Reset Instruction<br />

Syntax<br />

Reset<br />

Group<br />

File<br />

Description<br />

Close all open streams for the current macro/module.<br />

See Also: Close, Open.<br />

Example<br />

Sub Main<br />

' read the first line of XXX and print it<br />

Open "XXX" For Input As #1<br />

Line Input #1,L$<br />

Debug.Print L$<br />

Reset<br />

End Sub<br />

Resume Instruction<br />

Syntax<br />

Resume label<br />

-or-<br />

Resume Next<br />

Group<br />

Error Handling<br />

Description<br />

Form 1: Resume execution at label.<br />

Form 2: Resume execution at the next statement.<br />

Once an error has occurred, the error handler can use Resume to continue execution. The error handler must use<br />

Resume or Exit at the end.<br />

Note: This instruction clears the Err and sets Error$ to null.<br />

226


Example<br />

Sub Main<br />

On Error GoTo X<br />

Err.Raise 1<br />

Debug.Print "RESUMING"<br />

Exit Sub<br />

X: Debug.Print "Err=";Err<br />

Resume Next<br />

End Sub<br />

RGB Function<br />

Syntax<br />

RGB(red, green, blue)<br />

Group<br />

Miscellaneous<br />

Description<br />

Return a color.<br />

See Also: QBColor( ).<br />

Example<br />

Sub Main<br />

Debug.Print Hex(RGB(255,0,0)) '"FF0000"<br />

End Sub<br />

Right$ Function<br />

Syntax<br />

Right[$](S$, Len)<br />

Group<br />

String<br />

Description<br />

Return the last Len chars of S$.<br />

Note: A similar function, RightB, returns the last Len bytes.<br />

Parameter Description<br />

S$ Return the right portion of this string value. If this value is Null then Null is returned.<br />

227


Len Return this many chars. If S$ is shorter than that then just return S$.<br />

See Also: InStr( ), InStrRev( ), Left$( ), Len( ), Mid$( ), Replace$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Right$("Hello",3) '"llo"<br />

End Sub<br />

Right$ Function<br />

Syntax<br />

Right[$](S$, Len)<br />

Group<br />

String<br />

Description<br />

Return the last Len chars of S$.<br />

Note: A similar function, RightB, returns the last Len bytes.<br />

Parameter Description<br />

S$ Return the right portion of this string value. If this value is Null then Null is returned.<br />

Len Return this many chars. If S$ is shorter than that then just return S$.<br />

See Also: InStr( ), InStrRev( ), Left$( ), Len( ), Mid$( ), Replace$( ).<br />

Example<br />

Sub Main<br />

Debug.Print Right$("Hello",3) '"llo"<br />

End Sub<br />

RmDir Instruction<br />

Syntax<br />

RmDir Name$<br />

Group<br />

File<br />

Description<br />

Remove directory Name$.<br />

Parameter Description<br />

Name$ This string value is the path and name of the directory. A path relative to the current<br />

228


See Also: MkDir.<br />

Example<br />

Sub Main<br />

RmDir "C:\WWTEMP"<br />

End Sub<br />

Rnd Function<br />

Syntax<br />

Rnd([Num])<br />

Group<br />

Math<br />

Description<br />

229<br />

directory can be used.<br />

Return a random number greater than or equal to zero and less than one.<br />

Parameter Description<br />

Num See table below.<br />

Num Description<br />

0 Return the next random number in the sequence.<br />

0 Return the most recently generated number.<br />

omitted Return the next random number in the sequence.<br />

See Also: Randomize.<br />

Example<br />

Sub Main<br />

Debug.Print Rnd() ' 0.??????????????<br />

End Sub<br />

Round Function<br />

Syntax<br />

Round([Num][, Places])<br />

Group<br />

Math<br />

Description<br />

Return the number rounded to the specified number of decimal places.


Parameter Description<br />

Num Round this numeric value. If this value is Null then Null is returned.<br />

Places Round to this number of decimal places. If this is omitted then round to the nearest<br />

integer value.<br />

Example<br />

Sub Main<br />

Debug.Print Round(.5) ' 0<br />

Debug.Print Round(.500001) ' 1<br />

Debug.Print Round(1.499999) ' 1<br />

Debug.Print Round(1.5) ' 2<br />

Debug.Print Round(11.11) ' 11<br />

Debug.Print Round(11.11,1) ' 11.1<br />

End Sub<br />

RSet Instruction<br />

Syntax<br />

RSet strvar = str<br />

Group<br />

Assignment<br />

Description<br />

Assign the value of str to strvar. Shorten str by removing trailing chars (or extend with leading blanks). The<br />

previous length strvar is maintained.<br />

See Also: LSet.<br />

Example<br />

Sub Main<br />

S$ = "123"<br />

RSet S$ = "A"<br />

Debug.Print ".";S$;"." '". A."<br />

End Sub<br />

RTrim$ Function<br />

Syntax<br />

RTrim[$](S$)<br />

Group<br />

String<br />

230


Description<br />

Return the string with S$'s trailing spaces removed.<br />

Parameter Description<br />

S$ Copy this string without the trailing spaces. If this value is Null then Null is returned.<br />

See Also: LTrim$( ), Trim$( ).<br />

Example<br />

Sub Main<br />

Debug.Print ".";RTrim$(" x ");"." '". x."<br />

End Sub<br />

SaveSetting Instruction<br />

Syntax<br />

SaveSetting AppName$, Section$, Key$, Setting<br />

Group<br />

Settings<br />

Description<br />

Save the Setting for Key in Section in project AppName. Win16 and Win32s store settings in a .ini file named<br />

AppName. Win32 stores settings in the registration database.<br />

Parameter Description<br />

AppName$ This string value is the name of the project which has this Section and Key.<br />

Section$ This string value is the name of the section of the project settings.<br />

Key$ This string value is the name of the key in the section of the project settings.<br />

Setting Set the key to this value. (The value is stored as a string.)<br />

Example<br />

Sub Main<br />

SaveSetting "MyApp","Font","Size",10<br />

End Sub<br />

Second Function<br />

Syntax<br />

Second(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

231


Return the second of the minute (0 to 59).<br />

Parameter Description<br />

dateexpr Return the second of the minute for this date value. If this value is Null then Null is<br />

returned.<br />

See Also: Hour( ), Minute( ), Time( ).<br />

Example<br />

Sub Main<br />

Debug.Print Second(#12:00:01 AM#) ' 1<br />

End Sub<br />

Seek Function<br />

Syntax<br />

Seek(StreamNum)<br />

Group<br />

File<br />

Description<br />

Return StreamNum current position. For Random mode files this is the record number. The first record is 1.<br />

Otherwise, it is the byte position. The first byte is 1.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

See Also: Seek.<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

Debug.Print Seek(1) ' 1<br />

Line Input #1,L$<br />

Debug.Print Seek(1)<br />

Close #1<br />

End Sub<br />

Seek Instruction<br />

Syntax<br />

Seek [#]StreamNum, Count<br />

Group<br />

File<br />

232


Description<br />

Position StreamNum for input Count.<br />

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

Count For Random mode files this is the record number. The first record is 1. Otherwise, it<br />

is the byte position. The first byte is 1.<br />

See Also: Seek( ).<br />

Example<br />

Sub Main<br />

Open "XXX" For Input As #1<br />

Line Input #1,L$<br />

Seek #1,1 ' rewind to start of file<br />

Input #1,A<br />

Close #1<br />

Debug.Print A<br />

End Sub<br />

Select Case Statement<br />

Syntax<br />

Select Case expr<br />

[Case caseexpr[, ...]<br />

statements]...<br />

[Case Else<br />

statements]<br />

End Select<br />

Group<br />

Flow Control<br />

Description<br />

Select the appropriate case by comparing the expr with each of the caseexprs. Select the Case Else part if no<br />

caseexpr matches. (If the Case Else is omitted then skip the entire Select...End Select block.)<br />

caseexpr Description<br />

expr Execute if equal.<br />

Is < expr Execute if less than.<br />

Is expr Execute if greater than.<br />

Is >= expr Execute if greater than or equal to.<br />

Is expr Execute if not equal to.<br />

expr1 To expr2 Execute if greater than or equal to expr1 and less than or equal to expr2.<br />

See Also: If, Choose( ), IIf( ).<br />

Example<br />

Sub Main<br />

S = InputBox("Enter hello, goodbye, dinner or sleep:")<br />

233


Select Case UCase(S)<br />

Case "HELLO"<br />

Debug.Print "come in"<br />

Case "GOODBYE"<br />

Debug.Print "see you later"<br />

Case "DINNER"<br />

Debug.Print "Please come in."<br />

Debug.Print "Dinner will be ready soon."<br />

Case "SLEEP"<br />

Debug.Print "Sorry."<br />

Debug.Print "We are full for the night"<br />

Case Else<br />

Debug.Print "What?"<br />

End Select<br />

End Sub<br />

Select Case Statement<br />

Syntax<br />

Select Case expr<br />

[Case caseexpr[, ...]<br />

statements]...<br />

[Case Else<br />

statements]<br />

End Select<br />

Group<br />

Flow Control<br />

Description<br />

Select the appropriate case by comparing the expr with each of the caseexprs. Select the Case Else part if no<br />

caseexpr matches. (If the Case Else is omitted then skip the entire Select...End Select block.)<br />

caseexpr Description<br />

expr Execute if equal.<br />

Is < expr Execute if less than.<br />

Is expr Execute if greater than.<br />

Is >= expr Execute if greater than or equal to.<br />

Is expr Execute if not equal to.<br />

expr1 To expr2 Execute if greater than or equal to expr1 and less than or equal to expr2.<br />

See Also: If, Choose( ), IIf( ).<br />

Example<br />

Sub Main<br />

S = InputBox("Enter hello, goodbye, dinner or sleep:")<br />

Select Case UCase(S)<br />

Case "HELLO"<br />

Debug.Print "come in"<br />

Case "GOODBYE"<br />

Debug.Print "see you later"<br />

234


Case "DINNER"<br />

Debug.Print "Please come in."<br />

Debug.Print "Dinner will be ready soon."<br />

Case "SLEEP"<br />

Debug.Print "Sorry."<br />

Debug.Print "We are full for the night"<br />

Case Else<br />

Debug.Print "What?"<br />

End Select<br />

End Sub<br />

SendKeys Instruction<br />

Syntax<br />

SendKeys Keys$[, Wait]<br />

Group<br />

Miscellaneous<br />

Description<br />

Send Keys$ to Windows.<br />

Parameter Description<br />

Keys$ Send the keys in this string value to Windows. (Refer to table below.)<br />

Wait If this is not zero then the keys are sent before executing the next instruction. If this<br />

is omitted or zero then the keys are sent during the following instructions.<br />

Key Description<br />

+ Shift modifier key: the following key is a shifted key<br />

^ Ctrl modifier key: the following key is a control key<br />

% Alt modifier key: the following key is an alt key<br />

(keys) Modifiers apply to all keys<br />

~ Send Enter key<br />

k Send k Key (k is any single char)<br />

K Send Shift k Key (K is any capital letter)<br />

{special n} special key (n is an optional repeat count)<br />

{mouse x,y} mouse key (x,y is an optional screen position)<br />

{k} Send k Key (any single char)<br />

{K} Send Shift k Key (any single char)<br />

{Cancel} Send Break Key<br />

{Esc} Send Escape Key<br />

{Escape} Send Escape Key<br />

{Enter} Send Enter Key<br />

{Menu} Send Menu Key (Alt)<br />

{Help} Send Help Key (?)<br />

{Prtsc} Send Print Screen Key<br />

{Print} Send<br />

{Execute} Send ?<br />

{Tab} Send<br />

{Pause} Send Pause Key<br />

{Tab} Send Tab Key<br />

{BS} Send Back Space Key<br />

{BkSp} Send Back Space Key<br />

235


{BackSpace} Send Back Space Key<br />

{Del} Send Delete Key<br />

{Delete} Send Delete Key<br />

{Ins} Send Insert Key<br />

{Insert} Send Insert Key<br />

{Left} Send Left Arrow Key<br />

{Right} Send Right Arrow Key<br />

{Up} Send Up Arrow Key<br />

{Down} Send Down Arrow Key<br />

{PgUp} Send Page Up Key<br />

{PgDn} Send Page Down Key<br />

{Home} Send Home Key<br />

{End} Send End Key<br />

{Select} Send ?<br />

{Clear} Send Num Pad 5 Key<br />

{Pad0..9} Send Num Pad 0-9 Keys<br />

{Pad*} Send Num Pad * Key<br />

{Pad+} Send Pad + Key<br />

{PadEnter} Send Num Pad Enter<br />

{Pad.} Send Num Pad . Key<br />

{Pad-} Send Num Pad - Key<br />

{Pad/} Send Num Pad / Key<br />

{F1..24} Send F1 to F24 Keys<br />

Mouse<br />

Mouse movement and button clicks:<br />

• {Move x,y} - move the mouse to (x,y)<br />

• {ClickLeft x,y} - move the mouse to (x,y) and click the left button. (This is the same as {DownLeft<br />

x,y}{UpLeft}.)<br />

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

x,y}{ClickLeft}.)<br />

• {DownLeft x,y} - move the mouse to (x,y) and push the left button down.<br />

• {UpLeft x,y} - move the mouse to (x,y) and release the left button.<br />

• similarly named keys for the middle and right mouse buttons.<br />

The x,y values are screen pixel location (0,0) is in the upper-right. In all cases the x,y is optional. If omitted the<br />

previous mouse position is used.<br />

See Also: AppActivate, KeyName, Shell( ).<br />

Example<br />

Sub Main<br />

SendKeys "%S" ' send Alt-S (Search)<br />

SendKeys "GoTo~~" ' send G o T o {Enter} {Enter}<br />

End Sub<br />

Note<br />

In general, SendKeys cannot be used with characters higher than ASCII 127. Use Send<strong>Dragon</strong>Keys instead.<br />

Send<strong>Dragon</strong>Keys supports some characters that SendKeys does not support. For a table listing the names of<br />

nonprinting keys and the codes to use in Send<strong>Dragon</strong>Keys see the topic: Key names for Send<strong>Dragon</strong>Keys.<br />

236


Set Instruction<br />

Syntax<br />

Set objvar = objexpr<br />

-or-<br />

Set objvar = New objtype<br />

Group<br />

Assignment<br />

Description<br />

Form 1: Set objvar's object reference to the object reference of objexpr.<br />

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

The Set instruction is how object references are assigned.<br />

Example<br />

Sub Main<br />

Dim App As Object<br />

Set App = CreateObject("WinWrap.CppDemoApplication")<br />

App.Move 20,30 ' move icon to 20,30<br />

Set App = Nothing<br />

App.Quit ' run-time error (no object)<br />

End Sub<br />

SetAttr Instruction<br />

Syntax<br />

SetAttr Name$, Attrib<br />

Group<br />

File<br />

Description<br />

Set the attributes for file Name$. If the file does not exist then a run-time error occurs.<br />

Parameter Description<br />

Name$ This string value is the path and name of the file. A path relative to the current<br />

directory can be used.<br />

Attrib Set the file's attributes to this numeric value.<br />

Example<br />

Sub Main<br />

Attrib = GetAttr("XXX")<br />

SetAttr "XXX",1 ' readonly<br />

Debug.Print GetAttr("XXX") ' 1<br />

237


SetAttr "XXX",Attrib<br />

End Sub<br />

Sgn Function<br />

Syntax<br />

Sgn(Num)<br />

Group<br />

Math<br />

Description<br />

Return the sign.<br />

Parameter Description<br />

Num Return the sign of this numeric value. Return -1 for negative. Return 0 for zero.<br />

Return 1 for positive.<br />

Example<br />

Sub Main<br />

Debug.Print Sgn(9) ' 1<br />

Debug.Print Sgn(0) ' 0<br />

Debug.Print Sgn(-9) '-1<br />

End Sub<br />

Shell Function<br />

Syntax<br />

Shell(Name$[, WindowType])<br />

Group<br />

Miscellaneous<br />

Description<br />

Execute program Name$. This is the same as using File|Run from the Program Manager. This instruction can<br />

run .COM, .EXE, .BAT and .PIF files. If successful, return the task ID.<br />

Parameter Description<br />

Name$ This string value is the path and name of the program to run. Command line<br />

arguments follow the program name. (A long file name containing a space must be<br />

surrounded by literal double quotes.)<br />

WindowType This controls how the application's main window is shown. See the table below.<br />

WindowType Value Effect<br />

vbHide 0 Hide Window<br />

vbNormalFocus 1, 5, 9 Normal Window<br />

238


vbMinimizedFocus 2 Minimized Window (default)<br />

vbMaximizedFocus 3 Maximized Window<br />

vbNormalNoFocus 4, 8 Normal Deactivated Window<br />

vbMinimizedNoFocus 6, 7 Minimized Deactivated Window<br />

See Also: AppActivate, SendKeys.<br />

Example<br />

Sub Main<br />

X = Shell("Calc") ' run the calc program<br />

AppActivate X<br />

SendKeys "% R" ' restore calc's main window<br />

SendKeys "30*2{+}10=",1 '70<br />

End Sub<br />

ShowPopupMenu Function<br />

Syntax<br />

ShowPopupMenu(StrArray$( )[, PopupStyle][, XPos, YPos])<br />

Group<br />

User Input<br />

Description<br />

Show a popup menu and return the number of the item selected. The item number is the index of the StrArray<br />

selected minus LBound(StrArray). The value -1 is returned in no menu item is selected.<br />

Parameter Description<br />

StrArray$( ) This one-dimensional array of strings establishes the list of choices. All the<br />

non-null elements of the array are used.<br />

PopupMenuStyle This controls how the popup menu is aligned. Any combination of styles may<br />

used together. See the table below.<br />

XPos When the menu is put up the alignment will be at this window position. If this is<br />

omitted then the current mouse position is used.<br />

YPos When the menu is put up the alignment will be at this window position. If this is<br />

omitted then the current mouse position is used.<br />

PopupStyle Value Effect<br />

vbPopupLeftTopAlign 0 Align menu left edge at XPos and top at YPos. (default)<br />

vbPopupUseLeftButton 1 User can select menu choices with the left mouse button only.<br />

vbPopupUseRightButton 2 User can select menu choices with the left or right mouse<br />

button.<br />

vbPopupRightAlign 4 Align menu with right edge at the XPos.<br />

vbPopupCenterAlign 8 Align menu center at the XPos.<br />

vbPopupVCenterAlign 16 Align menu center at the YPos.<br />

vbPopupBottomAlign 32 Align menu bottom at the YPos.<br />

Example<br />

Sub Main<br />

Dim Items(0 To 2) As String<br />

Items(0) = "Item &1"<br />

239


Items(1) = "Item &2"<br />

Items(2) = "Item &3"<br />

X = ShowPopupMenu(Items) ' show popup menu<br />

Debug.Print X ' item selected<br />

End Sub<br />

Sin Function<br />

Syntax<br />

Sin(Num)<br />

Group<br />

Math<br />

Description<br />

Return the sine.<br />

Parameter Description<br />

Num Return the sine of this numeric value. This is the number of radians. There are 2*Pi<br />

radians in a full circle.<br />

Example<br />

Sub Main<br />

Debug.Print Sin(1) ' 0.8414709848079<br />

End Sub<br />

Space$ Function<br />

Syntax<br />

Space[$](Len)<br />

Group<br />

String<br />

Description<br />

Return the string Len spaces long.<br />

Parameter Description<br />

Len Create a string this many spaces long.<br />

See Also: String$( ).<br />

Example<br />

Sub Main<br />

Debug.Print ".";Space$(3);"." '". ."<br />

240


End Sub<br />

Sqr Function<br />

Syntax<br />

Sqr(Num)<br />

Group<br />

Math<br />

Description<br />

Return the square root.<br />

Parameter Description<br />

Num Return the square root of this numeric value.<br />

Example<br />

Sub Main<br />

Debug.Print Sqr(9) ' 3<br />

End Sub<br />

Statement definition<br />

Zero or more instructions. A statement is at least one line long. Begin Dialog, Do, For, If (multiline), Select Case,<br />

While and With statements are always more than one line long. A single line statement continues on the next line<br />

if it ends a line with a space and an underscore ' _'.<br />

S$ = "This long string is easier to read, " + _<br />

"if it is broken across two lines."<br />

Debug.Print S$<br />

Static Definition<br />

Syntax<br />

Static name[type][([dim[, ...]])][As [New] type][, ...]<br />

Group<br />

Declaration<br />

Description<br />

A static variable retains it value between procedure calls. Dimension var array(s) using the dims to establish the<br />

minimum and maximum index value for each dimension. If the dims are omitted then a scalar (single value)<br />

241


variable is defined. A dynamic array is declared using ( ) without any dims. It must be ReDimensioned before it can<br />

be used.<br />

See Also: Dim, Option Base, Private, Public, ReDim.<br />

Example<br />

Sub A<br />

Static X<br />

Debug.Print X<br />

X = "Hello"<br />

End Sub<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

A<br />

A ' prints "Hello"<br />

End Sub<br />

Stop Instruction<br />

Syntax<br />

Stop<br />

Group<br />

Flow Control<br />

Description<br />

Pause execution. If execution is resumed then it starts at the next instruction. Use End to terminate the macro<br />

completely.<br />

Example<br />

Sub Main<br />

For I = 1 To 10<br />

Debug.Print I<br />

If I = 3 Then Stop<br />

Next I<br />

End Sub<br />

Str definition<br />

An expression that returns a string result.<br />

"Hello"<br />

S$<br />

S$ + " Goodbye"<br />

S$ & " Goodbye"<br />

Mid$(S$,2)<br />

242


Str$ Function<br />

Syntax<br />

Str[$](Num)<br />

Group<br />

String<br />

Description<br />

Return the string representation of Num.<br />

Parameter Description<br />

Len Return the string representation of this numeric value. Positive values begin with a<br />

blank. Negative values begin with a dash '-'.<br />

See Also: CStr( ), Hex$( ), Oct$( ), Val( ).<br />

Example<br />

Sub Main<br />

Debug.Print Str$(9*9) ' 81<br />

End Sub<br />

Strarray definition<br />

A variable that holds an array of string values. The name of a string variable may be followed by a $.<br />

StrConv$ Function<br />

Syntax<br />

StrConv[$](Str,Conv)<br />

Group<br />

String<br />

Description<br />

Convert the string.<br />

Parameter Description<br />

Str Convert this string value. If this value is Null then Null is returned.<br />

Conv This numeric value indicates the type of conversion. See conversion table below.<br />

Conv Value Effect<br />

243


vbUpperCase 1 Convert to upper case.<br />

vbLowerCase 2 Convert to lower case.<br />

vbProperCase 3 Convert to proper case. (Not supported.)<br />

vbWide 4 Convert to wide. (Only supported for Win32 in eastern locales.)<br />

vbNarrow 8 Convert to narrow. (Only supported for Win32 in eastern locales.)<br />

vbKatakana 16 Convert to Katakana. (Only supported for Win32 in Japanese locales.)<br />

vbHiragana 32 Convert to Hiragana. (Only supported for Win32 in Japanese locales.)<br />

vbUnicode 64 Convert to Unicode. (Only supported for Win32.)<br />

vbFromUnicode 128 Convert from Unicode. (Only supported for Win32.)<br />

See Also: LCase$( ), StrComp( ), UCase$( ).<br />

Example<br />

Sub Main<br />

Dim B(1 To 3) As Byte<br />

B(1) = 65<br />

B(2) = 66<br />

B(3) = 67<br />

Debug.Print StrConv$(B,vbUnicode) '"ABC"<br />

End Sub<br />

String$ Function<br />

Syntax<br />

String[$](Len, Char|$)<br />

Group<br />

String<br />

Description<br />

Return the string Len long filled with Char or the first char of Char$.<br />

Parameter Description<br />

Len Create a string this many chars long.<br />

Char|$ Fill the string with this char value. If this is a numeric value then use the ASCII char<br />

equivalent. If this is a string value use the first char of that string. If this value is Null<br />

then Null is returned.<br />

See Also: Space$( ).<br />

Example<br />

Sub Main<br />

Debug.Print String$(4,65) '"AAAA"<br />

Debug.Print String$(4,"ABC") '"AAAA"<br />

End Sub<br />

244


StrReverse$ Function<br />

Syntax<br />

StrReverse[$](S)<br />

Group<br />

String<br />

Description<br />

Return the string with the characters in reverse order.<br />

Parameter Description<br />

S Return this string with the characters in reverse order.<br />

Example<br />

Sub Main<br />

Debug.Print StrReverse$("ABC") 'CBA<br />

End Sub<br />

Strvar definition<br />

A variable that holds one string value. The name of a string variable may be followed by a $.<br />

FirstName$<br />

Sub Definition<br />

Syntax<br />

[ | Private | Public | Friend ] _<br />

Sub name[([param[, ...]])]<br />

statements<br />

End Sub<br />

Group<br />

Declaration<br />

Description<br />

User defined subroutine. The subroutine defines a set of statements to be executed when it is called. The values of<br />

the calling arglist are assigned to the params. A subroutine does not return a result.<br />

Sub defaults to Public if Private, Public or Friend are not is specified.<br />

See Also: Declare, Function, Property.<br />

Example<br />

245


Sub IdentityArray(A()) ' A() is an array of numbers<br />

For I = LBound(A) To UBound(A)<br />

A(I) = I<br />

Next I<br />

End Sub<br />

Sub CalcArray(A(),B,C) ' A() is an array of numbers<br />

For I = LBound(A) To UBound(A)<br />

A(I) = A(I)*B+C<br />

Next I<br />

End Sub<br />

Sub ShowArray(A()) ' A() is an array of numbers<br />

For I = LBound(A) To UBound(A)<br />

Debug.Print "(";I;")=";A(I)<br />

Next I<br />

End Sub<br />

Sub Main<br />

Dim X(1 To 4)<br />

IdentityArray X() ' X(1)=1, X(2)=2, X(3)=3, X(4)=4<br />

CalcArray X(),2,3 ' X(1)=5, X(2)=7, X(3)=9, X(4)=11<br />

ShowArray X() ' print X(1), X(2), X(3), X(4)<br />

End Sub<br />

Tan Function<br />

Syntax<br />

Tan(Num)<br />

Group<br />

Math<br />

Description<br />

Return the tangent.<br />

Parameter Description<br />

Num Return the tangent of this numeric value.<br />

Example<br />

Sub Main<br />

Debug.Print Tan(1) ' 1.5574077246549<br />

End Sub<br />

Text Dialog Item Definition<br />

Syntax<br />

246


Text X, Y, DX, DY, Title$[, .Field][, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a text item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

the dialog's font.<br />

Title$ The value of this string is the title of the text control.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this identifer is omitted then the first two words of the title are used.<br />

Options This numeric value controls the alignment of the text. Choose one value from<br />

following table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 Text is left aligned.<br />

1 Text is right aligned.<br />

2 Text is centered.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

TextBox Dialog Item Definition<br />

Syntax<br />

TextBox X, Y, DX, DY, .Field$[, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a textbox item.<br />

247


Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is<br />

measured in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is<br />

measured in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height<br />

for the dialog's font.<br />

Field The value of the text box is accessed via this field.<br />

Options This numeric value controls the type of text box. Choose one value from following<br />

table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 Text box allows a single line of text to be entered.<br />

1 Text box allows multiple lines of text can be entered.<br />

-1 Text box allows a hidden password can be entered.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

TextBox 10,25,180,20,.Text$<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

dlg.Text$ = "none"<br />

Dialog dlg ' show dialog (wait for ok)<br />

Debug.Print dlg.Text$<br />

End Sub<br />

Text Dialog Item Definition<br />

Syntax<br />

Text X, Y, DX, DY, Title$[, .Field][, Options]<br />

Group<br />

User Dialog<br />

Description<br />

Define a text item.<br />

Parameter Description<br />

X This number value is the distance from the left edge of the dialog box. It is measured<br />

in 1/8ths of the average character width for the dialog's font.<br />

Y This number value is the distance from the top edge of the dialog box. It is measured<br />

in 1/12ths of the character height for the dialog's font.<br />

DX This number value is the width. It is measured in 1/8ths of the average character<br />

width for the dialog's font.<br />

DY This number value is the height. It is measured in 1/12ths of the character height for<br />

248


the dialog's font.<br />

Title$ The value of this string is the title of the text control.<br />

Field This identifier is the name of the field. The dialogfunc receives this name as string. If<br />

this identifer is omitted then the first two words of the title are used.<br />

Options This numeric value controls the alignment of the text. Choose one value from<br />

following table. (If this numeric value omitted then zero is used.)<br />

Option Description<br />

0 Text is left aligned.<br />

1 Text is right aligned.<br />

2 Text is centered.<br />

See Also: Begin Dialog, Dim As UserDialog.<br />

Example<br />

Sub Main<br />

Begin Dialog UserDialog 200,120<br />

Text 10,10,180,15,"Please push the OK button"<br />

OKButton 80,90,40,20<br />

End Dialog<br />

Dim dlg As UserDialog<br />

Dialog dlg ' show dialog (wait for ok)<br />

End Sub<br />

Time Function<br />

Syntax<br />

Time[$]<br />

Group<br />

Time/Date<br />

Description<br />

Return the current time as a date value.<br />

See Also: Date, Now, Timer.<br />

Example<br />

Sub Main<br />

Debug.Print Time ' example: 09:45:00 am<br />

End Sub<br />

Timer Function<br />

Syntax<br />

Timer<br />

249


Group<br />

Time/Date<br />

Description<br />

Return the number of seconds past midnight. (This is a real number, accurate to about 1/18th of a second.)<br />

See Also: Date, Now, Time.<br />

Example<br />

Sub Main<br />

Debug.Print Timer ' example: 45188.13<br />

End Sub<br />

TimeSerial Function<br />

Syntax<br />

TimeSerial(Hour, Minute, Second)<br />

Group<br />

Time/Date<br />

Description<br />

Return a date value.<br />

Parameter Description<br />

Hour This numeric value is the hour (0 to 23).<br />

Minute This numeric value is the minute (0 to 59).<br />

Second This numeric value is the second (0 to 59).<br />

See Also: DateSerial, DateValue, TimeValue.<br />

Example<br />

Sub Main<br />

Debug.Print TimeSerial(13,30,0) '1:30:00 PM<br />

End Sub<br />

TimeValue Function<br />

Syntax<br />

TimeValue(Date$)<br />

Group<br />

Time/Date<br />

250


Description<br />

Return the time part of date encoded as a string value.<br />

Parameter Description<br />

Date$ Convert this string value to the time part of date it represents.<br />

See Also: DateSerial, DateValue, TimeSerial.<br />

Example<br />

Sub Main<br />

Debug.Print TimeValue("1/1/2000 12:00:01 AM")<br />

'12:00:01 AM<br />

End Sub<br />

Trim$ Function<br />

Syntax<br />

Trim[$](S$)<br />

Group<br />

String<br />

Description<br />

Return the string with S$'s leading and trailing spaces removed.<br />

Parameter Description<br />

S$ Copy this string without the leading or trailing spaces. If this value is Null then Null is<br />

returned.<br />

See Also: LTrim$( ), RTrim$( ).<br />

Example<br />

Sub Main<br />

Debug.Print ".";Trim$(" x ");"." '".x."<br />

End Sub<br />

Type definition<br />

Variable and parameter types, as well as, function and property results may be specified using a type character as<br />

the last character in their name.<br />

Type char As Type<br />

% Integer<br />

? PortInt<br />

& Long<br />

! Single<br />

# Double<br />

@ Currency<br />

$ String<br />

251


Type Definition<br />

Syntax<br />

[ | Private | Public ] _<br />

Type name<br />

elem [([dim[, ...]])] As [New] type<br />

[...]<br />

End Type<br />

Group<br />

Declaration<br />

Description<br />

Define a new usertype. Each elem defines an element of the type for storing data. As [New] type defines the type<br />

of data that can be stored. A user defined type variable has a value for each elem. Use .elem to access individual<br />

element values.<br />

Type defaults to Public if neither Private or Public is specified.<br />

Example<br />

Type Employee<br />

FirstName As String<br />

LastName As String<br />

Title As String<br />

Salary As Double<br />

End Type<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Dim e As Employee<br />

e.FirstName = "John"<br />

e.LastName = "Doe"<br />

e.Title = "President"<br />

e.Salary = 100000<br />

Debug.Print e.FirstName '"John"<br />

Debug.Print e.LastName '"Doe"<br />

Debug.Print e.Title '"President"<br />

Debug.Print e.Salary ' 100000<br />

End Sub<br />

TypeName Function<br />

Syntax<br />

TypeName[$](var)<br />

252


Group<br />

Variable Info<br />

Description<br />

Return a string indicating the type of value stored in var.<br />

Parameter Description<br />

var Return a string indicating the type of value stored in this variable.<br />

Result Description<br />

Empty Variant variable is empty. It has never been assigned a value.<br />

Null Variant variable is null.<br />

Integer Variable contains an integer value.<br />

Long Variable contains a long value.<br />

Single Variable contains a single value.<br />

Double Variable contains a double value.<br />

Currency Variable contains a currency value.<br />

Date Variable contains a date value.<br />

String Variable contains a string value.<br />

Object Variable contains an object reference that is not Nothing. (An object may return a type<br />

name specific to that type of object.)<br />

Nothing Variable contains an object reference that is Nothing.<br />

Error Variable contains a error code value.<br />

Boolean Variable contains a boolean value.<br />

Variant Variable contains a variant value. (Only used for arrays of variants.)<br />

Unknown Variable contains a non-ActiveX Automation object reference.<br />

Byte Variable contains a byte value.<br />

( ) Variable contains an array value. The TypeName of the element followed by ( ).<br />

See Also: VarType.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

Debug.Print TypeName(X) '"Empty"<br />

X = 1<br />

Debug.Print TypeName(X) '"Integer"<br />

X = 100000<br />

Debug.Print TypeName(X) '"Long"<br />

X = 1.1<br />

Debug.Print TypeName(X) '"Double"<br />

X = "A"<br />

Debug.Print TypeName(X) '"String"<br />

Set X = CreateObject("Word.Basic")<br />

Debug.Print TypeName(X) '"Object"<br />

X = Array(0,1,2)<br />

Debug.Print TypeName(X) '"Variant()"<br />

End Sub<br />

UBound Function<br />

Syntax<br />

UBound(arrayvar[, dimension])<br />

253


Group<br />

Variable Info<br />

Description<br />

Return the highest index.<br />

Parameter Description<br />

arrayvar Return the highest index for this array variable.<br />

dimension Return the highest index for this dimension of arrayvar. If this is omitted then return<br />

the highest index for the first dimension.<br />

See Also: LBound( ).<br />

Example<br />

Sub Main<br />

Dim A(3,6)<br />

Debug.Print UBound(A) ' 3<br />

Debug.Print UBound(A,1) ' 3<br />

Debug.Print UBound(A,2) ' 6<br />

End Sub<br />

UCase$ Function<br />

Syntax<br />

UCase[$](S$)<br />

Group<br />

String<br />

Description<br />

Return a string from S$ where all the lowercase letters have been uppercased.<br />

Parameter Description<br />

S$ Return the string value of this after all chars have been converted to lowercase. If<br />

this value is Null then Null is returned.<br />

See Also: LCase$( ), StrComp( ), StrConv$( ).<br />

Example<br />

Sub Main<br />

Debug.Print UCase$("Hello") '"HELLO"<br />

End Sub<br />

Unlock Instruction<br />

Syntax<br />

254


Unlock StreamNum<br />

-or-<br />

Unlock StreamNum, RecordNum<br />

-or-<br />

Unlock StreamNum, [start] To end<br />

Group<br />

File<br />

Description<br />

Form 1: Unlock all of StreamNum.<br />

Form 2: Unlock a record (or byte) of StreamNum.<br />

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

record (or byte).<br />

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

Parameter Description<br />

StreamNum Streams 1 through 255 are private to each macro. Streams 256 through 511 are<br />

shared by all macros.<br />

RecordNum For Random mode files this is the record number. The first record is 1. Otherwise, it<br />

is the byte position. The first byte is 1.<br />

start First record (or byte) in the range.<br />

end Last record (or byte) in the range.<br />

See Also: Lock, Open.<br />

Example<br />

Sub Main<br />

Dim V As Variant<br />

Open "SAVE_V.DAT" For Binary As #1<br />

Lock #1<br />

Get #1, 1, V<br />

V = "Hello"<br />

Put #1, 1, V<br />

Unlock #1<br />

Close #1<br />

End Sub<br />

Userenum definition<br />

User defined enums are defined with Enum.<br />

Usertypevar definition<br />

A user defined type variable holds values for elements of the user defined type. User defined types are defined<br />

using Type.<br />

255


Declare with Dim, Private, Public or Static.<br />

Declare as a parameter of Sub, Function or Property definition.<br />

Uses Comment<br />

Syntax<br />

'#Uses "module" [Only:[Win16|Win32]] ...<br />

-or-<br />

'$Include: "module"<br />

Description<br />

The Uses comment indicates that the current macro/module uses public and friend symbols from the module. The<br />

Only option indicates that the module is only loaded for that Windows platform.<br />

Parameter Description<br />

module Public and Friend symbols from this module are accessible. If the module name is a<br />

relative path then the path is relative to the macro/module containing the Uses<br />

comment. For example, if module "A:\B\C\D.BAS" has this uses comment:<br />

'#Uses "E.BAS"<br />

then it uses "A:\B\C\E.BAS".<br />

See Also: Class Module, Code Module, Object Module.<br />

Example<br />

'Macro A.WWB<br />

'#Uses "B.WWB"<br />

Sub Main<br />

Debug.Print BFunc$("Hello") '"HELLO"<br />

End Sub<br />

'Module B.WWB<br />

Public Function BFunc$(S$)<br />

BFunc$ = UCase(S$)<br />

End Sub<br />

Val Function<br />

Syntax<br />

Val(S$)<br />

Group<br />

String<br />

Description<br />

Return the value of the S$.<br />

Parameter Description<br />

256


S$ Return the numeric value for this string value. A string value begins with &O is an<br />

octal number. A string value begins with &H is a hex number. Otherwise it is decimal<br />

number.<br />

Example<br />

Sub Main<br />

Debug.Print Val("-1000") '-1000<br />

End Sub<br />

Var definition<br />

A variable holds either a string, a numeric value or an array of values depending on its type.<br />

Variantvar definition<br />

A variant variable can hold any type of value (except String*n or usertypevar). or it can hold an array.<br />

VarType Function<br />

Syntax<br />

VarType(var)<br />

Group<br />

Variable Info<br />

Description<br />

Return a number indicating the type of value stored in var.<br />

Parameter Description<br />

var Return a number indicating the type of value stored in this variable.<br />

Result Value Description<br />

vbEmpty 0 Variant variable is empty. It has never been assigned a value.<br />

vbNull 1 Variant variable is null.<br />

vbInteger 2 Variable contains an integer value.<br />

vbLong 3 Variable contains a long value.<br />

vbSingle 4 Variable contains a single value.<br />

vbDouble 5 Variable contains a double value.<br />

vbCurrency 6 Variable contains a currency value.<br />

vbDate 7 Variable contains a date value.<br />

vbString 8 Variable contains a string value.<br />

vbObject 9 Variable contains an object reference.<br />

vbError 10 Variable contains a error code value.<br />

vbBoolean 11 Variable contains a boolean value.<br />

257


vbVariant 12 Variable contains a variant value. (Only used for arrays of variants.)<br />

vbDataObject 13 Variable contains a non-ActiveX Automation object reference.<br />

vbDecimal 14 Variable contains a 96 bit scaled real.<br />

vbByte 17 Variable contains a byte value.<br />

vbUserDefinedType 36 Variable contains a User Defined Type value.<br />

+vbArray 8192 Variable contains an array value. Use VarType( ) And 255 to get the<br />

type of element stored in the array.<br />

See Also: TypeName.<br />

Example<br />

Sub Main<br />

Dim X As Variant<br />

Debug.Print VarType(X) ' 0<br />

X = 1<br />

Debug.Print VarType(X) ' 2<br />

X = 100000<br />

Debug.Print VarType(X) ' 3<br />

X = 1.1<br />

Debug.Print VarType(X) ' 5<br />

X = "A"<br />

Debug.Print VarType(X) ' 8<br />

Set X = CreateObject("Word.Basic")<br />

Debug.Print VarType(X) ' 9<br />

X = Array(0,1,2)<br />

Debug.Print VarType(X) ' 8204 (8192+12)<br />

End Sub<br />

Wait Instruction<br />

Syntax<br />

Wait Delay<br />

Group<br />

Miscellaneous<br />

Description<br />

Wait for Delay seconds.<br />

Examples<br />

Sub Main<br />

Wait 5 ' wait for 5 seconds<br />

End Sub<br />

Sub Main<br />

Wait 0.5 ' wait for ½ second<br />

End Sub<br />

258


Weekday Function<br />

Syntax<br />

Weekday(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the weekday.<br />

vbSunday (1) - Sunday<br />

vbMonday (2) - Monday<br />

vbTuesday (3) - Tuesday<br />

vbWednesday (4) - Wednesday<br />

vbThursday (5) - Thursday<br />

vbFriday (6) - Friday<br />

vbSaturday (7) - Saturday<br />

Parameter Description<br />

dateexpr Return the weekday for this date value. If this value is Null then Null is returned.<br />

See Also: Date( ), Day( ), Month( ), WeekdayName( ), Year( ).<br />

Example<br />

Sub Main<br />

Debug.Print Weekday(#1/1/1900#) ' 2<br />

Debug.Print Weekday(#1/1/2000#) ' 7<br />

End Sub<br />

WeekdayName Function<br />

Syntax<br />

WeekdayName(NumZ{day}[, CondZ{abbrev}])<br />

Group<br />

Time/Date<br />

Description<br />

Return the localized name of the weekday.<br />

Parameter Description<br />

day Return the localized name of this weekday. (1-7)<br />

abbrev If this conditional value is True then return the abbreviated form of the weekday<br />

name.<br />

See Also: Weekday( ).<br />

259


Example<br />

Sub Main<br />

Debug.Print WeekdayName(1) 'Sunday<br />

Debug.Print WeekdayName(Weekday(Now))<br />

End Sub<br />

While Statement<br />

Syntax<br />

While condexpr<br />

statements<br />

Wend<br />

Group<br />

Flow Control<br />

Description<br />

Execute statements while condexpr is True.<br />

See Also: Do, For, For Each, Exit While.<br />

Example<br />

Sub Main<br />

I = 2<br />

While I < 10<br />

I = I*2<br />

Wend<br />

Debug.Print I ' 16<br />

End Sub<br />

With Statement<br />

Syntax<br />

With objexpr<br />

statements<br />

End With<br />

Group<br />

Object<br />

Description<br />

Method and property references may be abbreviated inside a With block. Use .method or .property to access the<br />

object specified by the With objexpr.<br />

260


Example<br />

Sub Main<br />

Dim App As Object<br />

Set App = CreateObject("WinWrap.CppDemoApplication")<br />

With App<br />

.Move 20,30 ' move icon to 20,30<br />

End With<br />

End Sub<br />

WithEvents Definition<br />

Syntax<br />

[Dim | Private | Public] _<br />

WithEvents name As objtype[, ...]<br />

Group<br />

Declaration<br />

Description<br />

Dimensioning a module level variable WithEvents allows the macro to implement event handling Subs. The<br />

variable's As type must be a type from a referenced type library (or language extension) which implements events.<br />

See Also: Dim, Private, Public.<br />

Example<br />

Dim WithEvents X As Thing<br />

C:\ABCTemp\vbs\Sub_Definition.htm<br />

Sub Main<br />

Set X = New Thing<br />

X.DoIt ' DoIt method raises DoingIt event<br />

End Sub<br />

C:\ABCTemp\vbs\Private_Keyword.htm<br />

Private Sub X_DoingIt<br />

Debug.Print "X.DoingIt event"<br />

End Sub<br />

Write Instruction<br />

Syntax<br />

Write #StreamNum, expr[, ...]<br />

Group<br />

File<br />

261


Description<br />

Write's expr(s) to StreamNum. String values are quoted. Null values are written as #NULL#. Boolean values are<br />

written as #FALSE# or #TRUE#. Date values are written as #date#. Error codes are written as #ERROR number#.<br />

See Also: Input, Line Input, Print.<br />

Example<br />

Sub Main<br />

A = 1<br />

B = 2<br />

C$ = "Hello"<br />

Open "XXX" For Output As #1<br />

Write #1,A,B,C$<br />

Close #1<br />

End Sub<br />

Year Function<br />

Syntax<br />

Year(dateexpr)<br />

Group<br />

Time/Date<br />

Description<br />

Return the year.<br />

Parameter Description<br />

dateexpr Return the year for this date value. If this value is Null then Null is returned.<br />

See Also: Date( ), Day( ), Month( ), Weekday( ).<br />

Example<br />

Sub Main<br />

Debug.Print Year(#1/1/1900#) ' 1900<br />

Debug.Print Year(#1/1/2000#) ' 2000<br />

End Sub<br />

Objects Overview<br />

ActiveX Automation provides access to objects in other applications. Each object supports a particular set of<br />

methods and properties. Each method/property has zero or more parameters. Parameters may be optional, in<br />

which case the parameter can be specified by using name := value.<br />

objexpr.method [expr][, ...] [param := expr][,...]<br />

Call method for objexpr.<br />

objexpr.method[([expr][, ...] [param := expr][,...])]<br />

262


263<br />

Return the value of method for objexpr.<br />

objexpr.property[([expr][, ...] [param := expr][,...])]<br />

Return the value of property for objexpr.<br />

objexpr[([expr][, ...] [param := expr][,...])]<br />

Return the default value for the objexpr.<br />

objexpr.property[([expr][, ...])] = expr<br />

Assign the value of property for objexpr.<br />

objexpr[([expr][, ...])] = expr<br />

Assign the default value for the objexpr.<br />

Set objexpr.property[([expr][, ...])] = objexpr<br />

Set the object reference of property for objexpr.<br />

Note: objexpr!name is shorthand for objexpr.defaultproperty("name"). Use objexpr![name] if name contains any<br />

characters that are not allowed in an identifier.<br />

Format Predefined Date<br />

Description<br />

The following predefined date formats may be used with the Format function. Predefined formats may not be<br />

combined with user defined formats or other predefined formats.<br />

Form Description<br />

General Date Same as user defined date format "c"<br />

Long Date Same as user defined date format "dddddd"<br />

Medium Date Not supported at this time.<br />

Short Date Same as user defined date format "ddddd"<br />

Long Time Same as user defined date format "ttttt"<br />

Medium Time Same as user defined date format "hh:mm AMPM"<br />

Short Time Same as user defined date format "hh:mm"<br />

Format Predefined Number<br />

Description<br />

The following predefined number formats may be used with the Format function. Predefined formats may not be<br />

combined with user defined formats or other predefined formats.<br />

Form Description<br />

General Number Return number as is.<br />

Currency Same as user defined number format "$#,##0.00;($#,##0.00)"<br />

Not locale dependent at this time.<br />

Fixed Same as user defined number format "0.00".<br />

Standard Same as user defined number format "#,##0.00".<br />

Percent Same as user defined number format "0.00%".<br />

Scientific Same as user defined number format "0.00E+00".<br />

Yes/No Return "No" if zero, else return "Yes".<br />

True/False Return "True" if zero, else return "False".


On/Off Return "On" if zero, else return "Off".<br />

Example<br />

Sub Main<br />

Debug.Print Format$(2.145,"Standard") ' 2.15<br />

End Sub<br />

Format User Defined Date<br />

Description<br />

The following date formats may be used with the Format function. Date formats may be combined to create the<br />

user defined date format. User defined date formats may not be combined with other user defined formats or<br />

predefined formats.<br />

Parameter Description<br />

: insert localized time separator<br />

/ insert localized date separator<br />

c insert ddddd ttttt, insert date only if t=0, insert time only if d=0<br />

d insert day number without leading zero<br />

dd insert day number with leading zero<br />

ddd insert abbreviated day name<br />

dddd insert full day name<br />

ddddd insert date according to Short Date format<br />

dddddd insert date according to Long Date format<br />

w insert day of week number<br />

ww insert week of year number<br />

m insert month number without leading zero<br />

insert minute number without leading zero (if follows h or hh)<br />

mm insert month number with leading zero<br />

insert minute number with leading zero (if follows h or hh)<br />

mmm insert abbreviated month name<br />

mmmm insert full month name<br />

q insert quarter number<br />

y insert day of year number<br />

yy insert year number (two digits)<br />

yyyy insert year number (four digits, no leading zeros)<br />

h insert hour number without leading zero<br />

hh insert hour number with leading zero<br />

n insert minute number without leading zero<br />

nn insert minute number with leading zero<br />

s insert second number without leading zero<br />

ss insert second number with leading zero<br />

ttttt insert time according to time format<br />

AM/PM use 12 hour clock and insert AM (hours 0 to 11) and PM (12 to 23)<br />

am/pm use 12 hour clock and insert am (hours 0 to 11) and pm (12 to 23)<br />

A/P use 12 hour clock and insert A (hours 0 to 11) and P (12 to 23)<br />

a/p use 12 hour clock and insert a (hours 0 to 11) and p (12 to 23)<br />

AMPM use 12 hour clock and insert localized AM/PM strings<br />

\c insert character c<br />

"text" insert literal text<br />

264


Format User Defined Number<br />

Description<br />

The following number formats may be used with the Format function. Number formats may be combined to create<br />

the user defined number format. User defined number formats may not be combined with other user defined<br />

formats or predefined formats.<br />

User defined number formats can contain up to four sections separated by ';':<br />

265<br />

form - format for non-negative expr, '-'format for negative expr, empty and null expr return ""<br />

form;negform - negform: format for negative expr<br />

form;negform;zeroform - zeroform: format for zero expr<br />

form;negform;zeroform;nullform - nullform: format for null expr<br />

Parameter Description<br />

# digit, don't include leading/trailing zero digits (all the digits left of decimal point<br />

are returned)<br />

eg. Format(19,"###") returns "19"<br />

eg. Format(19,"#") returns "19"<br />

0 digit, include leading/trailing zero digits<br />

eg. Format(19,"000") returns "019"<br />

eg. Format(19,"0") returns "19"<br />

. decimal, insert localized decimal point<br />

eg. Format(19.9,"###.00") returns "19.90"<br />

eg. Format(19.9,"###.##") returns "19.9"<br />

, thousands, insert localized thousand separator every 3 digits<br />

"xxx," or "xxx,." mean divide expr by 1000 prior to formatting<br />

two adjacent commas ",," means divide expr by 1000 again<br />

eg. Format(1900000,"0,,") returns "2"<br />

eg. Format(1900000,"0,,.0") returns "1.9"<br />

% percent, insert %, multiply expr by 100 prior to formatting<br />

: insert localized time separator<br />

/ insert localized date separator<br />

E+ e+ E- e- use exponential notation, insert E (or e) and the signed exponent<br />

eg. Format(1000,"0.00E+00") returns "1.00E+03"<br />

eg. Format(.001,"0.00E+00") returns "1.00E-03"<br />

- + $ ( ) space insert literal char<br />

eg. Format(10,"$#") returns "$10"<br />

\c insert character c<br />

eg. Format(19,"\####\#") returns "#19#"<br />

"text" insert literal text<br />

eg. Format(19,"""##""###""##""") returns "##19##"<br />

Example<br />

Sub Main<br />

Debug.Print Format$(2.145,"#.00") ' 2.15<br />

End Sub


Format User Defined Text<br />

Description<br />

The following text formats may be used with the Format function. Text formats may be combined to create the user<br />

defined text format. User defined text formats may not be combined with other user defined formats or predefined<br />

formats.<br />

User defined text formats can contain one or two sections separated by ';':<br />

266<br />

form - format for all strings<br />

form;nullform - nullform: format for empty and null strings<br />

Parameter Description<br />

@ char placeholder, insert char or space<br />

& char placeholder, insert char or nothing<br />

< all chars lowercase<br />

> all chars uppercase<br />

! fill placeholder from left-to-right (default is right-to-left)<br />

\c insert character c<br />

"text" insert literal text<br />

Example<br />

Sub Main<br />

Debug.Print Format("123","ab@c") '" ab1c23"<br />

Debug.Print Format("123","!ab@c") '" ab3c"<br />

End Sub<br />

Error List<br />

The following table lists all error codes with the associated error text.<br />

Error Description<br />

10000 Execution interrupted.<br />

10001 Out of memory.<br />

10008 Invalid '#Uses "module" comment.<br />

10009 Invalid '#Uses module dependency.<br />

10010 Macro is already running.<br />

10011 Can't allocate memory to macro/module.<br />

10012 Macro/module has syntax errors.<br />

10013 Macro/module does not exist.<br />

10014 Another macro is paused and can't continue at this time.<br />

10017 No macro is currently active.<br />

10018 Sub/Function does not exist.<br />

10019 Wrong number of parameters.<br />

10021 Can't allocate large array.<br />

10022 Array is not dimensioned.<br />

10023 Array index out of range.<br />

10024 Array lower bound is larger than upper bound.<br />

10025 Array has a different number of indexes.<br />

10030 User dialog has not been defined.<br />

10031 User pressed cancel.<br />

10032 User dialog item id is out of range.<br />

10033 No UserDialog is currently displayed.


10034 Current UserDialog is inaccessible.<br />

10035 Wrong with, don't GoTo into or out of With blocks.<br />

10040 Module could not be loaded.<br />

10041 Function not found in module.<br />

10048 File not opened with read access.<br />

10049 File not opened with write access.<br />

10050 Record length exceeded.<br />

10051 Could not open file.<br />

10052 File is not open.<br />

10053 Attempt to read past end-of-file.<br />

10054 Expecting a stream number in the range 1 to 511.<br />

10055 Input does not match var type.<br />

10056 Expecting a length in the range 1 to 32767.<br />

10057 Stream number is already open.<br />

10058 File opened in the wrong mode for this operation.<br />

10059 Error occurred during file operation.<br />

10060 Expression has an invalid floating point operation.<br />

10061 Divide by zero.<br />

10062 Overflow.<br />

10063 Expression underflowed minimum representation.<br />

10064 Expression loss of precision in representation.<br />

10069 String value is not a valid number.<br />

10071 Resume can only be used in an On Error handler.<br />

10075 Null value can't be used here.<br />

10080 Type mismatch.<br />

10081 Type mismatch for parameter #1.<br />

10082 Type mismatch for parameter #2.<br />

10083 Type mismatch for parameter #3.<br />

10084 Type mismatch for parameter #4.<br />

10085 Type mismatch for parameter #5.<br />

10086 Type mismatch for parameter #6.<br />

10087 Type mismatch for parameter #7.<br />

10088 Type mismatch for parameter #8.<br />

10089 Type mismatch for parameter #9.<br />

10090 OLE Automation error.<br />

10091 OLE Automation: no such property or method.<br />

10092 OLE Automation: server cannot create object.<br />

10093 OLE Automation: server cannot load file.<br />

10094 OLE Automation: Object var is 'Nothing'.<br />

10095 OLE Automation: server could not be found.<br />

10096 OLE Automation: no object currently active.<br />

10097 OLE Automation: wrong number of parameters.<br />

10098 OLE Automation: bad index.<br />

10099 OLE Automation: no such named parameter.<br />

10100 Directory could not be found.<br />

10101 File could not be killed.<br />

10102 Directory could not be created.<br />

10103 File could not be renamed.<br />

10104 Directory could not be removed.<br />

10105 Drive not found.<br />

10106 Source file could not be opened.<br />

10107 Destination file could not be created.<br />

10108 Source file could not be completely read.<br />

10109 Destination file could not be completely written.<br />

10110 Missing close brace '}'.<br />

10111 Invalid key name.<br />

10112 Missing close paren ')'.<br />

10113 Missing close bracket ']'.<br />

10114 Missing comma ','.<br />

267


10115 Missing semi-colon ';'.<br />

10116 SendKeys couldn't install the Windows journal playback hook.<br />

10119 String too long (too many keys).<br />

10120 Window could not be found.<br />

10130 DDE is not available.<br />

10131 Too many simultaneous DDE conversations.<br />

10132 Invalid channel number.<br />

10133 DDE operation did not complete in time.<br />

10134 DDE server died.<br />

10135 DDE operation failed.<br />

10140 Can't access the clipboard.<br />

10150 Window style must be in the range from 1 to 9.<br />

10151 Shell failed.<br />

10160 Declare is not implemented.<br />

10200 Basic is halted due to an unrecoverable error condition.<br />

10201 Basic is busy and can't provide the requested service.<br />

10202 Basic call failed.<br />

10203 Handler property: prototype specification is invalid.<br />

10204 Handler is already in use.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> scripting language extensions quick reference<br />

The <strong>Dragon</strong> <strong>NaturallySpeaking</strong> scripting language extensions provide a set of tools for creating <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> voice commands. See the topics guidelines for writing scripts and voice command list variables<br />

for more information on using the following:<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> scripting language extensions<br />

A<br />

ActiveControlPick ActiveMenuPick AppBringUp AppSwapWith<br />

B<br />

Beep ButtonClick<br />

C<br />

ClearDesktop ControlPick<br />

D<br />

DdeExecute DdePoke DllCall DragToPoint<br />

G<br />

GetState GoToSleep<br />

H<br />

HeardWord HTMLHelp<br />

M<br />

MenuCancel MenuPick MouseGrid MsgBoxConfirm MyCommandsActiveState<br />

P<br />

PlaySound PromptValue Function<br />

268


R<br />

RememberPoint RunScriptFile<br />

S<br />

Send<strong>Dragon</strong>Keys Send<strong>System</strong>Keys SetMicrophone SetMousePosition SetNaturalText SetState<br />

ShellExecute<br />

T<br />

TTSPlayString<br />

W<br />

Wait WaitForWindow WakeUp WinHelp<br />

Reference<br />

Key names Windows shortcut keys Error messages<br />

Guidelines for writing scripts<br />

Scripting commands have two parts: a command name and a set of arguments.<br />

Syntax<br />

CommandName "argument," [, argument]<br />

Rules<br />

Note<br />

269<br />

Command names are case-sensitive.<br />

Arguments in brackets ([ ]) are optional. Do not, however, include the brackets in scripts.<br />

Arguments must appear in the order shown, separated by commas. Spaces are optional.<br />

Enclose literal values (strings), including key sequences, in quotation marks. Do not enclose numeric values<br />

in quotation marks. To send a quotation mark as a literal, enclose it in quotations marks. For example,<br />

type: ""."<br />

Scripts can contain comments (text that is ignored when the script runs). Precede comments with a single<br />

quote (') character.<br />

Scripts cannot be used to activate or disable dictation words and voice commands. <strong>Dragon</strong> <strong>NaturallySpeaking</strong> does<br />

not support these distinct modes.<br />

List Variables<br />

A list is a variable part of a voice command name that is replaced by an actual item from a list of pre-defined<br />

variables.<br />

Move Cursor to is an example of a command that contains a list. The list, , can be replaced<br />

by one of a list of predefined values, including Top, Bottom, Beginning, and End.


Adding a list variable to a command name<br />

To add a list variable to a command name, type the list name with angle brackets. For example, type "Send Email<br />

to ", where Employee is the name of a new list.<br />

A command with a list can:<br />

270<br />

• Perform different actions depending on the particular list value that is used. For example, the command<br />

Move Cursor to performs a different action depending on the list value (Top, Bottom,<br />

Beginning, and End) used for .<br />

• Perform the same action but have different spoken forms. For example, the commands "Move to End of<br />

Line" and "Go to End of Line" are forms of the same command. The command includes the list ,<br />

which has two synonymous values: "Move to" and "Go to".<br />

You can use lists that are already defined or create your own. To include a list, type its name (enclosed in angle<br />

brackets) in the Command Name box. In the next step, you will be prompted to enter (or edit) the values for any<br />

lists you include.<br />

Notes<br />

• If the command will perform a different action depending on the list value used, the command can be<br />

implemented only with a script.<br />

• You can access the values of the lists from the script by means of the ListVarX() function, where X is of 1..20<br />

range. Once created, it appears in the Lists Already Defined box.<br />

• To refer to the value of a list variable, use the UtilityProvider object. UtilityProvider.ContextValue(n) returns<br />

a string containing the value of the nth list variable, where the variables are numbered starting with 0. (In<br />

debug mode, this same function returns the name of the variable, though you can change it to debug your<br />

script, see Debugging section below.) UtilityProvider.ContextValueCount returns the number of lists in the<br />

command name. For an example of a script using list variables, see the example custom command called<br />

"sample script ," which is in the user-defined global commands.<br />

Debugging<br />

In debug mode, ListVarX() and UtilityProvider.ContextValue(n) functions return the name of the corresponding<br />

variable. If you want these functions to return more meaningful values while debugging your script, you can use<br />

UtilityProvider.SetContextValue(n,value) function to set the necessary value. And to determine whether your<br />

script is being executed under the debugger you can query UtilityProvider.IsDebugMode boolean property. The<br />

following example will set the first list value to "5" and the second list value to "snakes", but only if the script is<br />

executed under debugger in MyCommands Editor.<br />

Sub Main<br />

If UtilityProvider.IsDebugMode Then<br />

UtilityProvider.SetContextValue(0,"5")<br />

UtilityProvider.SetContextValue(1,"snakes")<br />

End If<br />

MsgBox UtilityProvider.ContextValue(0) + " " + UtilityProvider.ContextValue(1)<br />

End Sub<br />

At runtime when the appropriate command gets recognized and the script is executed the<br />

UtilityProvider.IsDebugMode returns false and the list variables will be set to their appropriate values uttered by<br />

the speaker.<br />

ActiveControlPick<br />

Selects a control in an application that supports Microsoft Active Accessibility. Command buttons, option buttons,


check boxes, group boxes, list boxes, and text fields are examples of controls. Only controls within the currently<br />

active window are available.<br />

Some programs require Active Accessibility to select controls. Most applications do not require Active Accessibility<br />

and some system environments do not support it. Therefore, you should only use the ActiveControlPick command<br />

for applications that require Active Accessibility for control selection. For all other programs, use the ControlPick<br />

command or use the SendKeys command to press the control's accelerator key.<br />

Note<br />

This command works only for legacy <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 commands that have been imported into<br />

version 9. It will not work in commands that you create using the MyCommands editor.<br />

Syntax<br />

ActiveControlPick "menuItem"<br />

Argument Description<br />

menuItem Specifies the identifier assigned to the control to be selected. This value is typically<br />

the control's text label, and is case sensitive. Do not use a control's accelerator keys<br />

for this value. If the label includes an ampersand (&) prefixing an access key, do not<br />

include it.<br />

Example<br />

This example presses the OK button in the active window.<br />

Notes<br />

271<br />

ActiveControlPick "OK"<br />

• Generally, toolbar buttons, property sheet tabs, and taskbar buttons cannot be selected using<br />

ActiveControlPick.<br />

• A static text field, such as a text box label, can be selected only if it has an access key (underlined letter).<br />

ActiveMenuPick<br />

Selects the specified menu or menu item, visible in the active window, by executing the menu's access keys. This<br />

command works only in applications that support Microsoft Active Accessibility.<br />

Some programs require Active Accessibility to select menus. Most applications do not require Active Accessibility<br />

and some system environments do not support it. Therefore, you should only use the ActiveMenuPick command for<br />

applications that require Active Accessibility for menu selection. For all other programs, use the MenuPick<br />

command or use the SendKeys command to press an accelerator key.<br />

Note<br />

This command works only for legacy <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 commands that have been imported into<br />

version 9. It will not work in commands that you create using the MyCommands editor.<br />

Syntax<br />

ActiveMenuPick "menuItem"


Argument Description<br />

MenuItem The name (as displayed in the menu) of the menu or menu item to open. This value<br />

is case-sensitive.<br />

Example<br />

This example displays the File menu and then selects the Save As menu item.<br />

Notes<br />

272<br />

ActiveMenuPick "File"<br />

ActiveMenuPick "Save As"<br />

• If the menu name contains an ellipsis, do not include it in the menuItem value.<br />

• You may need to insert a Wait command between consecutive MenuPick commands to ensure that the first<br />

menu appears before selecting one of its entries.<br />

• A static text field, such as a text box label, can be selected only if it has an access key (underlined letter).<br />

AppBringUp<br />

Starts the specified application, or reactivates it if it is already running.<br />

Syntax<br />

AppBringUp "appName" [, "cmndLine" [,style[, "dir"]]]<br />

Argument Description<br />

appName A name you assign to the application to be started. This value can be used<br />

again in subsequent AppBringUp instructions to reactivate a running<br />

application. The value has meaning only to <strong>Dragon</strong> <strong>NaturallySpeaking</strong>; it has<br />

no effect on the application.<br />

If no other arguments are included, and the appName value has not been used<br />

in a previous AppBringUp or AppSwapWith command, AppBringUp looks for an<br />

executable file named appName in the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Program<br />

folder and in the directores that Windows searches when starting a program.<br />

cmndLine Specifies the application path and any command line switches, such as the<br />

name of a file to open. Long file names are not supported. For program names<br />

it is not necessary to include the extension .EXE.<br />

If the value contains a file name, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> starts the<br />

application specified (or, if no application is specified, the program associated<br />

with the file type) and opens the file.<br />

If this argument does not include a full file path, the file must be in the <strong>Dragon</strong><br />

NatuallySpeaking Program folder or in a directory that is searched when<br />

Windows starts a program.<br />

style A value indicating the window state in which to open the application. If the<br />

application is already running, this value has no effect.


273<br />

1 (default) Default window size; active<br />

2 Minimized window; active<br />

3 Maximized window; active<br />

4 Default window size; not active<br />

6 Minimized window; not active<br />

dir Specifies the default working directory for the application. The default value is<br />

the directory containing the program's executable file.<br />

Example 1<br />

This example starts or reactivates WordPad, opens the MyApp Readme file in a maximized window.<br />

AppBringUp "Readme", "Notepad C:\Program Files\Myapp\Readme.txt", 3<br />

This second instruction reactivates the specified application (it must be running) and file by using the same<br />

appName value.<br />

AppBringUp "Readme"<br />

Example 2<br />

This example copies text from the active application to the specified application when you say "Copy All to Word"<br />

or "Copy All to WordPad". In this example, the command name is "Copy All to " and the<br />

list consists of the words "Word" and "WordPad".<br />

Note<br />

SendKeys "^a^c"<br />

if _arg1 = "Word" then AppBringUp "WinWord"<br />

if _arg1 = "WordPad" then AppBringUp "WordPad"<br />

SendKeys "^v"<br />

Send<strong>System</strong>Keys "{Alt+Tab}"<br />

Scripting commands from <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 that use the <strong>Dragon</strong> List Variables will only function<br />

when the .dvc file is imported. You cannot create new commands using these old <strong>Dragon</strong> List Variables.<br />

AppSwapWith<br />

Switches the active application with the specified application. Starts the specified application if it is not already<br />

running.<br />

Syntax<br />

AppSwapWith "appName"<br />

Argument Description<br />

appName A name you assign to the application to switch to. If the specified application is<br />

not running, it is started.<br />

The value has meaning only to <strong>Dragon</strong> <strong>NaturallySpeaking</strong>; it has no effect on the<br />

application.


Beep<br />

274<br />

If the appName value has not been used in a previous AppBringUp or<br />

AppSwapWith command and the program is not running, an executable file<br />

named appName must be in the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Program folder or in<br />

a directory that is searched when Windows starts a program.<br />

Generates the Windows default beep sound by calling the Windows API MessageBeep() function. The exact result<br />

of this call depends on the hardware and system software configuration. On some systems with half-duplex sound<br />

systems, you must turn off the microphone before using this command for users to hear the beep.<br />

Syntax<br />

Beep<br />

This command does not have any arguments.<br />

Example<br />

The following script turns off the microphone, plays the beep sound, waits for five seconds to ensure that the sound<br />

finishes playing, and turns the microphone back on<br />

SetMicrophone 0<br />

Beep<br />

Wait 5<br />

SetMicrophone 1<br />

ButtonClick<br />

Generates a single or double click with the specified mouse button.<br />

Syntax<br />

ButtonClick [button[, count]]<br />

Argument Description<br />

button A value indicating which button is to be clicked. To click multiple mouse buttons<br />

simultaneously, add the values for each button to be clicked.<br />

1 (default) left button (button 1)<br />

2 right button (button 2)<br />

4 third (middle) button<br />

count A value indicating the number of clicks.<br />

1 (default) single click<br />

2 double click


Example<br />

This example generates a double-click with the left mouse button.<br />

Note<br />

275<br />

ButtonClick 1,2<br />

Use a series of ButtonClick commands to generate triple- or quadruple-clicks.<br />

ClearDesktop<br />

Minimizes all open applications.<br />

Syntax<br />

ClearDesktop<br />

This command does not have any arguments.<br />

ControlPick<br />

Selects a specified control in an active secondary window. Command buttons, option buttons, check boxes, group<br />

boxes, list boxes, and text fields are examples of controls. Generally, toolbar buttons, property sheet tabs, and<br />

taskbar buttons cannot be selected by using ControlPick.<br />

Syntax<br />

ControlPick "menuItem"<br />

Argument Description<br />

menuItem Specifies the identifier assigned to the control to be selected. This value is<br />

typically the control's text label, and is case sensitive. Do not use a control's<br />

accelerator keys for this value. If the label includes an ampersand (&) prefixing<br />

an access key, do not include it.<br />

Example<br />

This example presses the OK button in the active window.<br />

Notes<br />

ControlPick "OK"<br />

ControlPick does not work for nonstandard controls, such as an option with a bitmapped text label. You may<br />

be able to select a nonstandard control by using SendKeys to send a TAB sequence.<br />

A static text field, such as a text box label, can be selected only if it has an access key (underlined letter).


DdeExecute<br />

Sends a command or series of commands to a dynamic-data exchange (DDE) application.<br />

Syntax<br />

DdeExecute "appName", "topic", "command"[, async]<br />

Argument Description<br />

appName The name of the DDE application receiving the command. The appName value is<br />

usually the name of the application's .EXE file without the file name extension.<br />

The application must be running.<br />

topic The name of a topic recognized by the application. Many DDE applications<br />

recognize a topic named "<strong>System</strong>", which is always available. Each open<br />

document may also be a separate topic.<br />

command A command or series of commands recognized by the DDE application. Most<br />

applications require that each command received through a DDE channel be<br />

enclosed in square brackets. See Examples. Do not include spaces between<br />

bracketed commands.<br />

async If 0 or omitted, this call is synchronous and waits until the DDE application<br />

acknowledges completion or a timeout occurs. If 1, this call is asynchronous and<br />

returns immediately.<br />

Example 1<br />

This example opens a channel to Microsoft Excel and the <strong>System</strong> topic, and then sends a command to open<br />

EXPENSES.XLS. The document name must be enclosed in two sets of quotation marks.<br />

276<br />

DdeExecute "Excel", "<strong>System</strong>", "[OPEN(""Expenses.xls"")]"<br />

Example 2<br />

This example tells Microsoft Word to decrease the font size of selected text.<br />

Notes<br />

DdeExecute "WinWord", "<strong>System</strong>", "[ShrinkFont]"<br />

Use a DdeExecute instruction instead of SendKeys if you cannot be sure a key sequence always produces the<br />

same result. A key sequence can have different results depending on whether it is received by the<br />

application window or an open dialog box.<br />

Set async to 1 if you are calling a DDE command that does not return immediately. Otherwise, if the DDE<br />

command does not return quickly, DdeExecute fails with a timeout error and <strong>Dragon</strong> <strong>NaturallySpeaking</strong><br />

displays an error message.<br />

DdePoke<br />

Uses an open dynamic-data exchange (DDE) channel to send data to an application.<br />

Syntax


DdePoke "appName", "topic", "item", "value"<br />

Argument Description<br />

appName The name of the DDE application receiving the command. The application must be<br />

running.<br />

topic The name of the topic receiving the command.<br />

item An item within the specified DDE topic.<br />

value A string containing the data to send to the specified item.<br />

Example<br />

This example sends the string "Total: $1,216" to the second row and third column of the Expenses worksheet in<br />

Microsoft Excel.<br />

277<br />

DDEPoke "Excel", "Expenses", "R2C3", "Total: $1,216"<br />

DllCall<br />

Calls a function in an application's dynamic-link library (DLL). There are three forms of this command. The first<br />

does not return a value. The second is a function that returns an integer (LONG/DWORD) value. The third is a<br />

function that returns a string value.<br />

In the first two forms, the DLL function must be a PASCAL function that takes a single LPCSTR (long pointer to a<br />

constant string) argument. In the third form, the DLL function must take three arguments, an LPCSTR, a pointer<br />

to a BYTE buffer, and an integer.<br />

C or C++ DLL functions called by the first form of DllCall must have prototypes equivalent to:<br />

extern "C" __declspec(dllexport) void __stdcall fn(LPCTSTR szParam );<br />

C or C++ DLL functions called by the second form of DllCall must have prototypes equivalent to:<br />

extern "C" __declspec(dllexport) dword __stdcall fn(LPCTSTR szParam );<br />

C or C++ DLL functions called by the third form of DllCall must have prototypes equivalent to:<br />

extern "C" __declspec(dllexport) void __stdcall fn(LPCTSTR szParam , BYTE *pBuffer,<br />

int cMax);<br />

Syntax<br />

DllCall "libName", "function", "argString"<br />

integerVariable& = DllCall ("libName", "function", "argString")<br />

stringVariable$ = DllCall$ ("libName", "function", "argString", "maxStringLength")<br />

Argument Description<br />

libName The name of the .DLL file to be called. The DllCall command works even if the<br />

dynamic-link file does not have a .DLL extension. The value can be an<br />

expression.


function The name or number of the .DLL file function to call. If a number is used, do<br />

not enclose the value in quotation marks. The value cannot be an expression.<br />

argString The string containing the data to be passed to the dynamic-link function. The<br />

value can be an expression. This argument is passed as the first (or only)<br />

argument to the DLL function.<br />

maxStringLengt<br />

h<br />

Return Value Description<br />

integerVariable<br />

&<br />

278<br />

Maximum length of the string that the DLL can return as stringVariable.<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> uses this argument to reserve space for the string<br />

returned by the DLL call and passes it as the third argument to the DLL<br />

function. The value can be an expression.<br />

The Dll function must return an integer. DllCall sets integerVariable& to this<br />

value.<br />

stringVariable$ The Dll function must return a string by reference. DllCall sets<br />

stringVariable$ to the string value.<br />

Notes<br />

Improper use of the DllCall command can cause applications to hang and under some circumstances may<br />

require you to restart the computer. In particular, you should make sure that the form of the call and the<br />

argument string match the DLL function that you are calling.<br />

You can use the DllCall command to add application extensions to the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> scripting<br />

language.<br />

As a general rule, do not call Windows system .DLL files. However, you can write a DLL with functions that<br />

convert the contents of the stringArg from a single string into the appropriate arguments for a Windows<br />

DLL call and then make the required Windows calls.<br />

This command loads and releases the DLL each time you use it. If you make frequent DLLCalls to the same<br />

DLL, you can have another process load the DLL (and not unload it) to ensure that the DLL stays in<br />

memory.<br />

DragToPoint<br />

Positions the pointer in the last RememberPoint position, and then holds the mouse button and moves the mouse<br />

to the current pointer position.<br />

Syntax<br />

DragToPoint [buttons]<br />

Argument Description<br />

buttons A value indicating which button is to be pressed. To press multiple mouse buttons<br />

simultaneously, add the values for each button to be pressed.<br />

1 (default) left button (button 1)<br />

2 right button (button 2)


Example<br />

279<br />

4 third (middle) button<br />

This instruction positions the mouse pointer in the last RememberPoint location, presses the right mouse button,<br />

and then drags the pointer to the current pointer position.<br />

Notes<br />

DragToPoint 2<br />

DragtoPoint will have no effect if the RememberPoint command has not been used earlier in the script.<br />

This command does not work if you hold down any modifier keys (SHIFT, CTRL, ALT) when you run it.<br />

The DragToPoint command works only in applications that support dragging.<br />

GetState<br />

Returns the name of the active Structured State. The state of the commands are specified during their creation, so<br />

that at runtime, the groups of commands may be activated or deactivated using the SetState scripting command<br />

or the ActiveState property of the DgnEngineControl object in the MyCommands Advanced Scripting editor.<br />

Syntax<br />

GetState() As String<br />

The GetState function returns the string containing the name of the active state. If there is no state active, the<br />

returned value is an empty string.<br />

GoToSleep<br />

Activates sleep mode and the voice commands available for this state. The sleep mode vocabulary typically<br />

includes only the Wake Up command.<br />

Syntax<br />

GoToSleep<br />

Arguments<br />

This command does not have any arguments.<br />

HeardWord<br />

Causes <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to behave as if the specified word, word sequence, or voice command were<br />

received by the recognizer. You can use HeardWord to create a command that executes a series of other<br />

commands or that has the same function as an existing command but a different name.


Syntax<br />

HeardWord "word1" [, "word2", . . .]<br />

Argument Description<br />

word A single word in the active vocabulary or a single item in a command list. A list<br />

item can contain multiple words. This argument is case-sensitive.<br />

Example 1<br />

280<br />

Up to eight word values can be specified, separated by commas. A series of word<br />

values is recognized as a single continuous phrase.<br />

This example types a closing remark, in bold type, at the end of a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> document.<br />

HeardWord "go", "to", "bottom"<br />

HeardWord "set", "font", "bold"<br />

Wait 1<br />

Send<strong>Dragon</strong>Keys "{Enter 2}" + "This document was dictated using <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong>."<br />

Example 2<br />

This example automates the task of copying text between windows.<br />

Notes<br />

HeardWord "copy", "all", "to", "clipboard"<br />

HeardWord "switch", "to", "previous", "window"<br />

HeardWord "paste", "that"<br />

• If a word has different written and spoken forms, use the written form for the word value. If a word in a list<br />

has different written and spoken forms, use the entire list entry.<br />

• Use a single backslash before dictation commands that do not have a written form. For example, use<br />

HeardWord "\No-Caps". To see the words that need this treatment, open the Vocabulary Editor and scroll to<br />

the top.<br />

• If a dictation vocabulary word (such as "Academy Awards") consists of more than one dictionary word, put<br />

the vocabulary word in a single argument.<br />

HTMLHelp<br />

Calls the Microsoft HTML Help API. This command enables you to display HTML Help and close HTML Help windows.<br />

For more information on the HTML Help API, see the Microsoft HTML Help documentation.<br />

Syntax<br />

The following sections provide the syntax for each supported HTML Help API commands and describe the<br />

command's function. They use the following common parameter names:<br />

Parameter Description<br />

helpFile The name of the complied HTML Help file to open, for example, dragon_enx.chm. If<br />

you do not specify a full path, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> looks in the currently


281<br />

active <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Help folder. If the file is not found there, the<br />

normal HTML Help file search rules apply.<br />

topic The specific HTML topic to display. If the compiled help uses subdirectories, this<br />

parameter must include the subdirectory. For example, this topic is<br />

scrptref/htmlhelp.htm. Note that the identifier uses a forward slash (/).<br />

window The name of the window in which to display the HTML Help, for example, main. This<br />

parameter is always optional.<br />

HH_DISPLAY_TOPIC<br />

HTMLHelp "helpFile[>window]", "HH_DISPLAY_TOPIC", "topic"<br />

Opens the specified topic.<br />

HH_DISPLAY_TOC<br />

HTMLHelp "helpFile[::/topic][>window]", "HH_DISPLAY_TOC"<br />

Displays the Table of Contents navigation pane and opens the specified topic, if any.<br />

HH_DISPLAY_INDEX<br />

HTMLHelp "helpFile[::/topic][>window]", "HH_DISPLAY_INDEX", "[indexSearchText]"<br />

Displays the Index navigation pane and enters the indexSearchText string, if any, in the keyword field.<br />

HH_HELP_CONTEXT<br />

HTMLHelp "helpFile[>window]", "HH_HELP_CONTEXT", "ContextId"<br />

Displays the Help topic for the specified contextId in the specified window. The contextId must be the numeric ID<br />

in the [MAP] section of the Help project (.hhp) file for the topic to display.<br />

HH_CLOSE_ALL<br />

HTMLHelp "", "HH_CLOSE_ALL"<br />

Closes all HTML Help Windows opened by this program. The first argument must be an empty pair of double<br />

quotes.<br />

Examples<br />

HH_DISPLAY_TOC<br />

This instruction opens dragon_enx.chm in the default window, displays the Contents tab in the navigation pane,<br />

and displays the htmlhelp.htm topic (this topic) in the topic pane.<br />

HTMLHelp "dragon_enx.chm::/scrptref/htmlhelp.htm, "HH_DISPLAY_TOC"<br />

HH_HELP_CONTEXT<br />

This instruction opens MyProg.chm in a Help window named "HiddenNav" and displays the topic with the context<br />

ID 133096 (Hex 207E8).<br />

Notes<br />

HTMLHelp "C:\\MyProg\Help\MyProg.chm>HiddenNav", "HH_HELP_CONTEXT", "133096"<br />

• <strong>Dragon</strong> <strong>NaturallySpeaking</strong> does not get error returns from the HTML Help engine. As a result, it cannot<br />

display any messages when an HTML Help error occurs.<br />

• If the HTML Help file name does not use an absolute path, The HTMLHelp command first checks in the <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> Help directory for the requested help file. If the file is not found, the he normal HTML Help<br />

file search rules apply.


MenuCancel<br />

Cancels the active menu and any parent menus.<br />

Syntax<br />

MenuCancel<br />

Arguments<br />

This command does not have any arguments.<br />

Note<br />

The MenuCancel command is seldom needed in an application-specific command. Application-specific commands<br />

are not recognized when Windows is in a special mode such as when a menu is active or while a window is being<br />

moved or sized.<br />

MenuPick<br />

Selects the specified menu or menu item, visible in the active window, by executing the menu's access keys.<br />

Syntax<br />

MenuPick "menuItem"<br />

Argument Description<br />

menuItem The name (as displayed in the menu) of the menu or menu item to open. This value<br />

is case-sensitive.<br />

Example<br />

This example displays the File menu and then selects the Save As menu item.<br />

Notes<br />

282<br />

MenuPick "File"<br />

Wait 1<br />

MenuPick "Save As"<br />

If the menu name contains an ellipsis, do not include it in the menuItem value.<br />

You may need to insert a Wait command between consecutive MenuPick commands to ensure that the first<br />

menu appears before selecting one of its entries.<br />

MouseGrid<br />

Opens or resizes MouseGrid, a utility for positioning the mouse pointer.<br />

Syntax


MouseGrid [state[, gridbox]]<br />

Argument Description<br />

state A value indicating whether MouseGrid is sized relative to the screen or the active<br />

window.<br />

283<br />

1<br />

(default)<br />

Open MouseGrid relative to the screen or resize an open MouseGrid. If<br />

no gridbox value is specified, restore MouseGrid it to its previous size<br />

or to fit the screen.<br />

2 Open MouseGrid relative to the active window or resize an open<br />

MouseGrid. If no gridbox value is specified, restore MouseGrid it to its<br />

previous size or to fit the screen.<br />

0 Turn MouseGrid off (or leave it off).<br />

gridbox A value indicating the numbered area of the screen, window, or open MouseGrid<br />

to which MouseGrid is to be sized, as follows: (The value 0 undoes the last<br />

MouseGrid action.)<br />

Example<br />

1 2 3<br />

4 5 6<br />

7 8 9<br />

This example opens or resizes MouseGrid to fit in the upper-left corner of the active window.<br />

Note<br />

MouseGrid 2,1<br />

If MouseGrid reaches a point in which it would become unreadable if further resized, it moves, rather than resizes<br />

to, the specified gridbox value.<br />

MsgBoxConfirm<br />

Displays a standard Windows message box with the specified attributes.<br />

Syntax<br />

MsgBoxConfirm "msg", type, "title"<br />

Argument Description<br />

msg The text to be displayed in the message box. Up to 1024 characters can be<br />

displayed. Text wraps automatically.<br />

type A value indicating which buttons and which symbol appear in the message box,<br />

and which button is the default. The value is the sum of selected values from the<br />

following three groups:


284<br />

16 critical symbol (stop sign)<br />

32 warning query symbol (question mark). The Microsoft Windows Interface<br />

Guidelines for Software Design discourages using this icon.<br />

48 warning symbol (exclamation mark)<br />

64 information symbol (lowercase i)<br />

+<br />

0 OK button<br />

1 OK and Cancel buttons<br />

4 Yes and No buttons<br />

5 Retry and Cancel buttons<br />

+<br />

0 first button is the default<br />

256 second button is the default<br />

title The text to be displayed in the message box title bar.<br />

Example<br />

This instruction displays a message box with a warning symbol and Yes and No buttons. The first button, "Yes", is<br />

the default. (48 + 4 + 0 = 52)<br />

Notes<br />

MsgBoxConfirm "Do you want to save changes?", 52, "Warning"<br />

• The script automatically terminates if the user selects the Cancel or No button in the message box.<br />

• <strong>Dragon</strong> <strong>NaturallySpeaking</strong> editions through 3.01 do not support using the second button as a default.<br />

MyCommandsActiveState<br />

Syntax<br />

Visual Basic<br />

DgnEngineControl.MyCommandsActiveState As String<br />

C++<br />

HRESULT DgnEngineControl::get_MyCommandsActiveState( BSTR * StateName );<br />

HRESULT DgnEngineControl::put_MyCommandsActiveState( BSTR StateName );<br />

Description<br />

Returns or sets active Structured State for the MyCommands, so that you can dynamically activate or deactivate<br />

a set of commands, specific to a particular state in a window or application.


Parameters<br />

Argument Description<br />

StateName The name of the active MyCommands Structured State.<br />

PlaySound<br />

Plays the specified sound file. This command turns the microphone off while the sound plays. The next command<br />

in the script executes when the sound file stops playing.<br />

Syntax<br />

PlaySound "fileName.wav"<br />

Argument Description<br />

fileName.wa<br />

v<br />

Example<br />

285<br />

The name of the sound file to play and, optionally, its path. If no path is specified,<br />

the file must be in the <strong>Dragon</strong> NatuallySpeaking Program folder or in a directory<br />

that is searched when Windows starts a program. The .wav extension is not<br />

needed.<br />

This example plays the standard Windows chimes sound.<br />

PlaySound "C:\Windows\Media\Chimes.wav"<br />

PromptValue Function<br />

Syntax<br />

Visual Basic<br />

DgnEngineControl.PromptValue( Values As String, Description As String, Optional X As Long = -1,<br />

Optional Y As Long = -1 ) As String<br />

C++<br />

HRESULT IDgnEngineControl::PromptValue (SAFEARRAY (BSTR)* Values, BSTR Descrription, int X, int<br />

Y, BSTR * ChosenValue);<br />

Description<br />

Displays a Prompt box with a list of values from which the user can select an option. This allows you to create<br />

scripting commands with behavior that is dependent on the user's response. While the Prompt box is active, the<br />

user can select a value via mouse or voice.


Argument Description<br />

Values The array of values that will be shown to the user. In order to group values, you<br />

can use an empty string. This string appears as a separator element in the<br />

array. The values can optionally contain a word's spoken form, separated by<br />

backslash symbol (see example below).<br />

Description The caption that appears on the prompt box.<br />

X, Y Optional. Screen coordinates of the Prompt-box. If you do not supply these<br />

parameters, the Prompt-box will try to determine the most appropriate<br />

coordinates, basing on the current caret position.<br />

ChosenValue The return value; this is either the value selected by the user, or an empty<br />

string if the user dismissed the prompt box without making a selection.<br />

To access PromptValue, use the EngineControl object. EngineControl.PromptValue returns a string that contains<br />

the value chosen by the user, or an empty string if the Prompt-box was dismissed.<br />

Example<br />

....<br />

Dim Values(7) As String<br />

'Build a list of commands to display in the prompt dialog<br />

Values (0) = "milk"<br />

Values (1) = "cream"<br />

Values (2) = "eggs"<br />

Values (3) = "butter"<br />

Values (4) = "yogurt"<br />

Values (5) = "cheese"<br />

Values (6) = "chicken pot pie ingredients"<br />

Values (7) = "next"<br />

'set state to null before displaying prompt dialog<br />

SetState ""<br />

PROMPT_LIST:<br />

Dim item As String<br />

item = EngineControl.PromptValue (Values(), "Available Dairy")<br />

....<br />

RememberPoint<br />

Records the current mouse pointer position. You must use this command to record a starting point position before<br />

you can use a DragToPoint command.<br />

Syntax<br />

RememberPoint<br />

Arguments<br />

This command does not have any arguments.<br />

286


RunScriptFile<br />

Runs a <strong>Dragon</strong> <strong>NaturallySpeaking</strong> script contained in the specified file. The script file can contain only valid <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> scripting commands.<br />

Syntax<br />

RunScriptFile "fileName"<br />

Argument Description<br />

fileName The name of the file containing the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> script to be run. The<br />

file must be in ANSI text format.<br />

Example<br />

287<br />

If no path is specified, the file must be in the <strong>Dragon</strong> NatuallySpeaking Program<br />

folder or in a directory that is searched when Windows starts a program.<br />

This example runs a script contained in a file named Automate.txt.<br />

RunScriptFile "Automate.txt"<br />

Send<strong>Dragon</strong>Keys<br />

Sends keystrokes to the active window. If Send<strong>Dragon</strong>Keys fails to send the specified keystrokes, try using<br />

Send<strong>System</strong>Keys.<br />

Syntax<br />

Send<strong>Dragon</strong>Keys "type this"<br />

Argument Description<br />

type this The keystrokes to be sent to the active window. Enclose the names of nonprinting<br />

keys in braces ({ }). To specify a shift-key combination, enclose the modifier key<br />

name (such as Alt), a plus sign (+), and the shifted key in braces. To repeat a<br />

keystroke or key combination, enclose the key name, a space, and the number of<br />

repetiitions in braces.<br />

Example 1<br />

This instruction sends three CTRL+RIGHT keystrokes to the active window.<br />

Send<strong>Dragon</strong>Keys "{Ctrl+Right 3}"<br />

Example 2<br />

This example carries out the Set Font command by sending the Font dialog box access keys and the value<br />

of the list variable ListVAR1 (the keystrokes that set the font to the spoken face). Plus signs are used to<br />

concatenate the keystroke strings and the variable.<br />

Send<strong>Dragon</strong>Keys "{Alt+o}f{Alt+f}"+ListVAR1+"{Enter}"


Notes<br />

• Scripting commands from <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 that use the <strong>Dragon</strong> List Variables will only<br />

function when the .dvc file is imported. You cannot create new commands using these old <strong>Dragon</strong> List<br />

Variables.<br />

• Sending uppercase characters is equivalent to sending SHIFT plus the character. For example, A and<br />

{Shift+a} are equivalent.<br />

• Do not include spaces between the names of simultaneously pressed keys, such as Alt+Tab.<br />

• Any modifier keys (SHIFT, CTRL, ALT) pressed while the Send<strong>Dragon</strong>Keys command executes do not affect<br />

the command action.<br />

• You should test the use of Send<strong>Dragon</strong>Keys under varying conditions to avoid unpredictable results.<br />

• Use a DdeExecute instruction, rather than Send<strong>Dragon</strong>Keys, if you cannot be sure a key sequence always<br />

produces the same result.<br />

• You can use 0 to indicate zero repetitions of a key. This feature is useful for scripts where a keystroke may<br />

be used 0 or more times, depending upon a variable value.<br />

Send<strong>System</strong>Keys<br />

Sends keystrokes to the Windows operating system. Use this command only when SendKeys fails to perform. You<br />

can use Send<strong>System</strong>Keys to send key combinations such as {Ctrl+Esc}, {Alt+Esc}, and {Alt+Tab}.<br />

Syntax<br />

Send<strong>System</strong>Keys "keystroke text" [, speed]<br />

Argument Description<br />

keystroke<br />

text<br />

288<br />

The keystrokes to be sent to the Windows operating system. Enclose the names of<br />

nonprinting keys in braces ({ }).<br />

speed A value between 1 and 32767 indicating the keystroke speed. The default value is<br />

100; 200 is twice as fast as the default.<br />

Example<br />

This instruction executes the "Switch to Next Window" command.<br />

Notes<br />

Send<strong>System</strong>Keys "{Alt+Esc}"<br />

• Do not include spaces between the names of simultaneously-pressed keys, such as Alt+Tab.<br />

• Any modifier keys (SHIFT, CTRL, ALT) pressed while the Send<strong>System</strong>Keys command executes affect the<br />

command action.<br />

• The Send<strong>System</strong>Keys command sends keystrokes more slowly than the SendKeys command. Also, if the<br />

system responds slowly long strings can overflow the system keyboard buffer.


SetMicrophone<br />

Turns the microphone on or off.<br />

Syntax<br />

SetMicrophone [onOff]<br />

Argument Description<br />

onOff A value indicating the microphone state. If no value is specified, the microphone<br />

switches to the opposite state.<br />

Example<br />

289<br />

0 off<br />

1 on<br />

This example turns the microphone on.<br />

Note<br />

SetMicrophone 1<br />

SetMicrophone is used in the Microphone Off command.<br />

SetMousePosition<br />

Positions the mouse pointer by using absolute or relative coordinates. You can use SetMousePosition to position<br />

the mouse for selecting objects that do not have accelerator keys and that do not change position.<br />

Syntax<br />

SetMousePosition relativeTo, x[, y]<br />

Argument Description<br />

relativeTo A value indicating the reference point for the specified mouse pointer position.<br />

0 Coordinates are relative to the upper-left corner of the screen.<br />

1 Coordinates are relative to the upper-left corner of the active window.<br />

2 Coordinates are relative to the current pointer position.<br />

5 Coordinates are relative to the upper-left corner of the window interior (area<br />

within the window borders).<br />

3 The x-coordinate is one of nine mapped positions relative to the screen.<br />

4 The x-coordinate is one of nine mapped positions relative to the active<br />

window.<br />

6 The x-coordinate is one of nine mapped positions relative to the window


290<br />

interior (area within the window borders).<br />

x A value indicating the x-coordinate for the mouse position. Value must be an<br />

integer. If relativeTo is 1, 2, or 5, x is in pixels and positive values move the<br />

pointer right. If relativeTo is 3, 4 or 6, x must be a number between 0 and 8<br />

corresponding to one of nine mapped positions as follows:<br />

8 1 5<br />

4 0 2<br />

7 3 6<br />

y A value indicating the y-coordinate for the mouse position, in pixels. Value must<br />

be an integer. Positive values move the pointer down. If the value of relativeTo is<br />

3, 4 or 6, do not include a value for y.<br />

Example<br />

This instruction positions the mouse pointer relative to the upper-left corner of the active window, 300 pixels to the<br />

right and 200 down.<br />

Notes<br />

SetMousePosition 1, 300, 200<br />

• To select objects, use SetMousePosition followed by a ButtonClick command.<br />

• Target only objects that are always in the same position.<br />

• If the specified coordinate values would place the pointer off the screen, <strong>Dragon</strong> <strong>NaturallySpeaking</strong> displays<br />

an error message or positions the pointer as close as possible to the targeted position.<br />

SetNaturalText<br />

Turns general dictation (NaturalText), on or off. This command turns on and off the ability to dictate into text<br />

applications and fields that are not specifically supported by <strong>Dragon</strong> <strong>NaturallySpeaking</strong>. You can always dictate into<br />

supported applications including <strong>Dragon</strong>Pad, Microsoft Word, Lotus Notes, and so on.<br />

Syntax<br />

SetNaturalText [onOff]<br />

Argument Description<br />

onOff A value indicating the general dictation state. If no value is specified, the ability to<br />

dictate in all applications switches to the opposite state.<br />

Example<br />

0 off<br />

1 on<br />

This example turns general dictation on.


291<br />

SetNaturalText 1<br />

SetState<br />

Activates the specified Structured State and the commands associated with it as long as their availability also<br />

matches the foreground window. The states of the commands are specified during their creation, so that at runtime,<br />

the groups of commands can be activated or deactivated using the SetState scripting command or the ActiveState<br />

property of the DgnEngineControl object in the MyCommands Advanced Scripting editor.<br />

Syntax<br />

SetState( NewState As String )<br />

Argument Description<br />

NewState The name of the state to activate. If an empty string is specified, any current<br />

active state will be deactivated.<br />

Any previous Structured State will be deactivated together with associated commands.<br />

ShellExecute<br />

Loads an application. If a copy of the application is already running, it loads a new instance of the application.<br />

Syntax<br />

ShellExecute "commandLine"[, windowStyle[, "directory" ["applicationName"]]]<br />

Argument Description<br />

commandLine Specifies the executable file to run and any command line arguments. You do<br />

not have to include the application's .exe extension. If commandLine does not<br />

specify a full file path, the application must be in the the <strong>Dragon</strong><br />

NatuallySpeaking Program folder or in a directory that is searched when<br />

Windows starts a program. You cannot use long file names or include spaces in<br />

the executable path.<br />

windowStyle Controls how the window appears when you activate the application. Must be<br />

one of the following:<br />

1, 5, or 9 default window size; active (default)<br />

2 minimized window; active<br />

3 maximized window; active<br />

4 or 8 default window size; not active<br />

6 or 7 minimized window; not active<br />

directory Assigns a working directory for the application. The default is the directory


applicationNam<br />

e<br />

Example<br />

292<br />

that contains the executable file.<br />

Lets you name the application. This name is used by the AppBringUp and<br />

AppSwapWith commands. The application name must be unique. ShellExecute<br />

reports an error if the name is already in use.<br />

This instruction starts an instance of WordPad with its window maximized and sets the working directory to<br />

C:\DOCS. This instance of WordPad has the name "letter", and you can now use the AppBringUp and AppSwapWith<br />

scripting commands with the argument "letter" to activate the window while it is open.<br />

ShellExecute "WordPad", 3, "c:\docs", "letter"<br />

TTSPlayString<br />

Sends an instruction to the text-to-speech utility. The microphone is turned off while the command executes. The<br />

user can stop output by pressing the ESC key or turning on the microphone.<br />

Syntax<br />

TTSPlayString ["text" [, "switches"]]<br />

Argument Description<br />

text The text string to be read back by using the text-to-speech utility. If no text is<br />

included, or an empty string ("") is sent, the command reads the contents of the<br />

Clipboard.<br />

switches A series of values specifying the speed and volume of text-to-speech output.<br />

Example 1<br />

Switches are optional and may override text-to-speech preferences set by the<br />

user. Switches can be used in any order.<br />

/s A number between 0 and 255 indicating the playback speed. The default<br />

value is 127.<br />

/l A number between 0 and 255 indicating the playback volume relative to the<br />

current volume control setting. The default value, 255, reads text at a<br />

volume equal to this volume setting.<br />

This instruction reads the specified text at a moderate speed and at a volume equal to the current output volume.<br />

TTSPlayString "Click the microphone button to start", "/s80 /l255"<br />

Example 2<br />

This instruction reads a word-processor document by copying it to the Clipboard and sending a TTSPlayString<br />

command. Playback is at a slow speed.<br />

HeardWord "copy", "all", "to", "clipboard"<br />

TTSPlayString "", "/s90"


Wait<br />

Causes the script to pause for the specified number of milliseconds before executing the next command.<br />

Note<br />

This command works only for legacy <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 commands that have been imported into<br />

version 8. It will not work in commands that you create using the MyCommands editor. If you are creating a<br />

command from the MyCommands editor, use the Wait Instruction command.<br />

Syntax<br />

Wait milliseconds<br />

Argument Description<br />

millisecond<br />

s<br />

Example<br />

293<br />

A value from 0 to 32,767 indicating the number of milliseconds to wait.<br />

This example causes the script to pause for 100 milliseconds (one tenth of a second) before continuing.<br />

Notes<br />

Wait 100<br />

• You can use the Wait command to ensure that an application has enough time to load before the script<br />

continues.<br />

• To pause a script for longer than 32,767 milliseconds (32 seconds), use a loop to repeat the Wait command.<br />

• In many cases, this command stops recognition. However, recognition does continue where it is appropriate,<br />

for example, when the previous command is a MsgBoxConfirm command (to allow spoken responses to the<br />

message box).<br />

WaitForWindow<br />

The WaitFor Window command suspends execution of the script until a desired window appears in the foreground.<br />

Note<br />

This command works only for legacy <strong>Dragon</strong> <strong>NaturallySpeaking</strong> version 5 commands that have been imported into<br />

version 8. It will not work in commands that you create using the MyCommands editor.<br />

Syntax<br />

WaitForWindow caption [, windowClass [, timeout ] ]<br />

Argument Description<br />

caption A text string to match against the window caption. The string may (and often will)<br />

include the asterisk (*) character as a wild-card to match against variable parts of


windowClas<br />

s<br />

294<br />

the window caption. If parts of the actual window caption are guaranteed to be<br />

unpredictable, you MUST use an * wild-card to get a successful match.<br />

The caption may also be an empty string "", to indicate that the caption does not<br />

matter.<br />

A text string which, when not empty (""), must exactly match (case-sensitive) the<br />

window class name of the window you are looking for. The window class name is<br />

usually obtainable only through programmer utilities like "Spy".<br />

timeout The length of time, in milliseconds, to wait for the window to appear. If no<br />

matching window appears by then, a timeout error is displayed, and the script<br />

stops without executing any subsequent commands following WaitForWindow. If<br />

not specified, defaults to 10 seconds.<br />

Examples<br />

In the following example the * in the caption is an instruction to ignore "Document1".<br />

AppBringUp "(correct path here)winword.exe"<br />

WaitForWindow "*Microsoft Word"<br />

SendKeys "this text will appear in the Word document, not the splash screen"<br />

The following example waits for Word's main window by class name.<br />

AppBringUp "(correct path here)winword.exe"<br />

WaitForWindow "", "OpusApp"<br />

SendKeys "this text will appear in the Word document, not the splash screen"<br />

The following example starts Outlook, waits as long as 30 seconds in case the network is slow, and then types<br />

Alt+n to create a new E-mail.<br />

AppBringUp "(correct path)outlook.exe"<br />

WaitForWindow "*Microsoft Outlook", "", 30000<br />

Send<strong>System</strong>Keys "{Alt+n}"<br />

WakeUp<br />

Exits sleep mode and activates the microphone.<br />

Syntax<br />

WakeUp<br />

Arguments<br />

This command does not have any arguments.<br />

Note<br />

WakeUp is used in the Wake Up command.


WinHelp<br />

Activates the Windows Help application and specified Help (.HLP) file, and then displays the specified window or<br />

topic.<br />

Syntax<br />

WinHelp "helpFile", cmd, data<br />

Argument Description<br />

helpFile The name of the Help (.HLP) file to activate. If no path is specified, <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> looks for the file in the <strong>Dragon</strong> <strong>NaturallySpeaking</strong> Help folder.<br />

If the file is not found there, the normal Windows Help file search rules apply. The<br />

Help file name can be followed by the name of the Help system window in which to<br />

display the help, in the form ">WindowName".<br />

cmd A value identifying the Help topic to display.<br />

295<br />

1 Display the Help topic identified by the data argument.<br />

2 Close the Windows Help application.<br />

3 Display the default Help Contents topic. This topic is defined either in the<br />

Help project (.hpj) file or by a previous WinHelp command with a cmd value<br />

of 5. If there is no Contents topic, WinHelp displays the first topic in the Help<br />

file.<br />

4 Display Help for Windows Help.<br />

5 Set the topic specified in the data argument as the Help Contents topic. Does<br />

not display the Help file.<br />

8 Display in a popup window the Help topic identified by the data argument.<br />

9 Switch to the specified Help file. Open it with the first topic if the file is not<br />

already open. (Useful if another Help file has the focus.)<br />

11 Display the Help Topics dialog box. The tab used most recently is displayed.<br />

data Identifies the Help topic to open. This value must be the decimal number value of<br />

a Help context identifier assigned to a topic ID in the [MAP] section of the .hpj file.<br />

This value is required if the cmd value is 1, 5, or 8.<br />

Example<br />

This instruction opens Myapp.hlp in a Help window named "main" and displays the topic with the context ID<br />

133096 (Hex 207E8).<br />

WinHelp "C:\Program Files\Myapp\Myapp.hlp>main", 1, 133096<br />

Key names for Send<strong>Dragon</strong>Keys<br />

This table lists the names of nonprinting keys and the codes to use in these Advanced Scripting commands:<br />

Send<strong>Dragon</strong>Keys and Send<strong>System</strong>Keys.


Key Key Code<br />

ALT {Alt}<br />

BACKSPACE {BackSpace}<br />

BREAK {Break}<br />

CAPS LOCK {CapsLock}<br />

CENTER {Center}<br />

CONTROL {Ctrl}<br />

DEL {Del}<br />

DOWN ARROW {Down}<br />

END {End}<br />

ENTER {Enter}<br />

ESC {Esc}<br />

HELP {F1}<br />

HOME {Home}<br />

INS {Ins}<br />

LEFT ARROW {Left}<br />

NUM LOCK {NumLock} (extended keyboards only)<br />

PAGE DOWN {PgDn}<br />

PAGE UP {PgUp}<br />

PAUSE {Pause}<br />

PRINT SCREEN {Prtsc}<br />

RIGHT ARROW {Right}<br />

SCROLL LOCK {ScrollLock}<br />

SHIFT {Shift}<br />

SPACE {Space}<br />

SYS REQ {SysReq}<br />

TAB {Tab}<br />

UP ARROW {Up}<br />

F1, F2,<br />

F3,...F16<br />

Numeric keypad<br />

296<br />

{F1}, {F2}, {F3},...{F16}<br />

{NumKey/}, {NumKey*}, {NumKey-}{NumKey+}<br />

{NumKey0},...{NumKey9}<br />

{NumKey.}, {NumKeyEnter}<br />

(These codes are handled as if NUM LOCK were on)


Extended Keys<br />

These keystrokes are generated by the extended keypad keys that are available on most keyboards. Most<br />

applications treat them the same as the corresponding keystrokes that do not have the Ext prefix (listed in the<br />

preceding table).<br />

{ExtDel} {ExtDown} {ExtEnd} {ExtHome} {ExtIns} {ExtLeft} {ExtPgDn} {ExtPgUp} {ExtRight} {ExtUp}<br />

Notes<br />

• Always precede the BREAK key with the CONTROL key.<br />

• CENTER is the non-NUM LOCK version of NUM KEY 5.<br />

• If you need to specify one of two ALT, CTRL, or SHIFT keys, use {LeftAlt} or {RightAlt}, {LeftCtrl} or<br />

{RightCtrl}, and {LeftShift} or {RightShift}.<br />

Windows shortcut keys<br />

This table lists some standard Windows shortcut keys you can use in keystroke commands and script commands.<br />

Keystrokes Action<br />

{Ctrl+Tab} or {Ctrl+PgDn} Switch to the next tab in a dialog box.<br />

{Ctrl+Shift+Tab} or<br />

{Ctrl+PgUp}<br />

Switch to the previous tab in a dialog box.<br />

{Tab} Move to the next option or group of option buttons.<br />

{Shift+Tab} Move to the previous option or group of option buttons.<br />

Arrow keys Move within the active list box or group of option buttons.<br />

{Space} Select the active command button or check box.<br />

Letter keys Move to the next item beginning with that letter in an active list<br />

box.<br />

{Alt+letter key} Select the item with that underlined letter.<br />

{Alt+Down} Display a drop-down list box.<br />

{Esc} Close a drop-down list box.<br />

{Enter} Choose the default command button.<br />

{Esc} Cancel the command and close the dialog box.<br />

Error messages for scripts<br />

Scripts may not run properly in every situation. Some scripts depend on certain options and settings. If a script<br />

cannot run, it displays an error message.<br />

If a command you have created produces an error or does nothing, open the command by using the Command<br />

Browser and check the following information:<br />

• If the command is application-specific, is the correct window or dialog box active when you say the<br />

command? If yes, does the title of the active window match the title specified?<br />

• If the command includes a list, do the list values match what you said?<br />

• If the command includes keystrokes, are braces included around keystrokes? Are the correct key codes<br />

used?<br />

• If the command runs a script, do the script commands follow proper syntax? Are quotation marks used to<br />

enclose strings, including keystroke strings?<br />

297


• If the command name contains punctuation (for example, "What Time Is It?"), did you verbalize the<br />

punctuation?<br />

Structured Commands<br />

About Structured Commands<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> Professional, Medical and Legal include an extension to text and graphics commands<br />

that let you to set the values of variables in text blocks based on voice input.<br />

You can create simple text and graphics commands with variables in the My Commands Editor dialog box without<br />

having to do extensive programming in Microsoft® VBA.<br />

Application states<br />

Structured commands let you control the action of a command based on the existence of a state in the application.<br />

For example, when you assign a state to each field in a form, the same command can perform different actions<br />

depending on which field is activated.<br />

You can use Advanced Scripting methods to control the states within structured commands or to set the initial state<br />

from a non-structured command. You can also create structured commands that prompt the user to select values<br />

from a predefined list.<br />

When the user speaks a command, the user is presented with a list of pre-defined values for the command. Once<br />

the user selects a value, the value is inserted into the correct location in the macro.<br />

Samples<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> includes several sample text and graphics commands with variables and sample<br />

structured commands. You can import the samples into <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to use them as templates for<br />

your own commands. The sample commands are fully commented.<br />

For more information, see:<br />

Structured Commands Samples<br />

298<br />

Importing Sample Commands<br />

Methods<br />

For more information on the methods used by the sample commands, refer to the following:<br />

Global Methods<br />

SetState<br />

GetState<br />

EngineControl Methods<br />

MyCommandsActiveState<br />

PromptValue<br />

Structured Commands Samples<br />

<strong>Dragon</strong> <strong>NaturallySpeaking</strong> includes several sample text and graphics commands with variables and sample<br />

structured commands. You can import the samples into <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to use them as templates for


your own commands. The sample commands are fully commented.<br />

Sample location<br />

The sample commands are installed in:<br />

\Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>NaturallySpeaking</strong>9\Data\Enx\samplecommands<br />

A shortcut to this directory is available on the Windows Start menu. To open this directory, click Start, point to<br />

Programs, then point to <strong>Dragon</strong> <strong>NaturallySpeaking</strong> 8, and click Sample Commands.<br />

Importing Sample Commands<br />

You can import the samples into <strong>Dragon</strong> <strong>NaturallySpeaking</strong> to use them as templates for your own commands. For<br />

information, see Importing Sample Commands<br />

Samples<br />

The following samples are included with <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

299<br />

GroceryListSample_<strong>Dragon</strong>Pad<br />

GroceryListSample_<strong>Dragon</strong>Pad.xml contains Advanced Scripting commands that simulate an on-line grocery<br />

order form in <strong>Dragon</strong>Pad. It demonstrates how to set and change command states, activating and deactivating<br />

various state structured commands, and how to use the command prompt. The voice command "Prepare<br />

Grocery List" causes the first section of a grocery list to display in <strong>Dragon</strong>Pad and sets a command state. Each<br />

section of the grocery list is designed to have a separate state. The voice command "What's Available" will<br />

prompt the user with a set of grocery list commands that are active in the given section.<br />

GroceryListSample_WordPad<br />

GroceryListSample_WordPad.xml contains Advanced Scripting commands similar to those of<br />

GroceryListSample_<strong>Dragon</strong>Pad.xml. It demonstrates how to set and change command states and to use the<br />

command prompt in WordPad and uses a different coding style. The same voice command "Prepare Grocery<br />

List" will start the grocery list in WordPad, activate the initial grocery list state, and prompt the user with a set<br />

of grocery list commands that are active in the given state. To read more about this sample and its commands,<br />

refer to the code comments in the XML file.<br />

SampleBoilerPlate_ColonCancer<br />

SampleBoilerPlate_ColonCancer.xml contains Advanced Scripting commands that demonstrate how to use<br />

structured commands and the command prompt for boilerplate text. This sample is modeled after a colon<br />

cancer checklist and is designed to work in Microsoft Word 2003. The voice command "Colon Cancer Checklist"<br />

causes the boilerplate text to display and takes the user, field by field, through the checklist.<br />

SampleBoilerPlate_EndoBiopsy<br />

SampleBoilerPlate_EndoBiopsy.xml contains a single Advanced Scripting macro that demonstrates how to set<br />

up boilerplate text and use the command prompt to guide users in filling the boilerplate text without using states.<br />

This sample is modeled after an endoscopic biopsy report and is designed to work in Microsoft Word 2003. The<br />

voice command "Prepare Endoscopic Biopsy Gross Template" causes the boilerplate text to display and takes<br />

the user, field by field, through the report.<br />

SampleTGV_Restaurant<br />

SampleTGV_Restaurant.xml contains Text and Graphics and Advanced Scripting commands that are used in<br />

<strong>Dragon</strong>Pad to simulate an ordering system for a Chinese and Japanese restaurant. This sample demonstrates<br />

how to set states for structured commands as well as how the same commands can be used to produce different<br />

results in different states. The voice command "Chinese Restaurant" or "Japanese Restaurant" starts the<br />

ordering system and activates the structured commands created for the given state. The voice command "Exit<br />

Ordering <strong>System</strong>" ends the ordering session.


300<br />

SetStateSample<br />

SetStateSample.xml contains simple Text and Graphics commands that demonstrate how to use variables and<br />

text formats and Advanced Scripting commands to set and unset a command state. This sample is designed to<br />

work in <strong>Dragon</strong>Pad with the initial command "Sample Set State". When the command executes, a command<br />

state is set for <strong>Dragon</strong>Pad and a simple exchange of greetings is simulated between the user and the system.<br />

The user speaks the greeting, e.g. "Good Morning", and the system responds in bold red text. When the user<br />

says "Good-bye", the exchange is terminated and the command state is unset.<br />

SampleInjuryReport<br />

SampleInjuryReport.xml together with SampleInjuryReport.dot demonstrates how structured commands and<br />

Microsoft Word templates can be used together to create a voice-enabled form filling environment. The<br />

template is a mock injury report with several text and checkbox fields can be filled using the commands included<br />

in the XML file. You start a form filling session with the voice command "Edit Report" spoken in a new document<br />

based on the sample template. Both the template and the commands are designed to work in Microsoft Word<br />

2003.<br />

Importing Structured Commands<br />

You can import existing structured commands, such as the Structured Commands Samples, into <strong>Dragon</strong><br />

<strong>NaturallySpeaking</strong> to use as templates for your own commands. Use the following procedure to import the sample<br />

structured commands that are supplied with <strong>Dragon</strong> <strong>NaturallySpeaking</strong>:<br />

To import the sample structured commands:<br />

1. On the <strong>Dragon</strong>Bar Tools menu, click Command Browser to open the Command Browser window.<br />

2. Click the Manage button on the Command Browser toolbar.<br />

3. In the Manage area, click the Import button, and in the Import Commands window choose MyCommands<br />

XML files from the Files of type list.<br />

4. Use the Import Commands window to browse to the Documents and Settings\All Users\Application<br />

Data\Nuance\<strong>NaturallySpeaking</strong>9\Data\Enx\samplecommands directory.<br />

5. Select one of the sample .XML files (for example, sampletgv_restaurant.xml) and click Open.<br />

6. Click OK on the Import Commands validation dialog box and then click Import on the Import Commands<br />

window to import the commands contained in the file.<br />

Note: The syntax of XML command files is defined by a document type definition (DTD) file that resides on the<br />

Nuance web site. When you import an XML command file, the application gives you the option of validating the<br />

syntax of the XML file against the DTD. The validation step is useful if you receive a XML command file from<br />

another person and want to check it for syntax errors prior to importing it.<br />

Click OK on the success message and return to the Manage area of the Command Browser.<br />

To examine the sample code<br />

Open the Command Browser and click the Manage button.<br />

Expand and select the appropriate item (for example, “ Menu”)<br />

Click the To Script button and then click the Edit button.<br />

The My Commands Editor dialog box opens with the command you selected entered into it. You can examine and<br />

modify the command with the My Commands Editor.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!