Miscellaneous

<< Click to Display Table of Contents >>

Navigation:  Reference (Scripting) > VBScript Basics >

Miscellaneous

 

InputBox Function

 

Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.

 
TIP: Use the Docklight-specific DL.InputBox2 method for a dialog box that always appears on the same screen as the Docklight Scripting main window. Or see the DL.GetKeyState function on how to wait and react to keyboard or mouse input.  

 

Syntax

 

result = InputBox (prompt[, title][, default][, xpos][, ypos][, helpfile, context])
 

Part

Description

prompt

Required.  String expression displayed as the message in the dialog box. The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used. If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return plus linefeed character combination (Chr(13) & Chr(10)) between each line.

title

Optional. String expression displayed in the title bar of the dialog box. If you omit title, the application name is placed in the title bar.

default

Optional. String expression displayed in the text box as the default response if no other input is provided. If you omit default, the text box is displayed empty.

xpos

Optional. Numeric expression that specifies, in twips, the horizontal distance of the left edge of the dialog box from the left edge of the screen. If xpos is omitted, the dialog box is horizontally centered.

ypos

Optional. Numeric expression that specifies, in twips, the vertical distance of the upper edge of the dialog box from the top of the screen. If ypos is omitted, the dialog box is vertically positioned approximately one-third of the way down the screen.

helpfile

Optional. String expression that identifies the Help file to use to provide context-sensitive Help for the dialog box. If helpfile is provided, context must also be provided.

context

Optional. Numeric expression that identifies the Help context number assigned by the Help author to the appropriate Help topic. If context is provided, helpfile must also be provided.

 

'Example InputBox Function

Dim MyInput

MyInput = InputBox("Please enter text", "My Title", "Example Text")

DL.AddComment MyInput   ' Add the current input as comment

 

MsgBox Function

 

Displays a message box, waits for the user to click a button, and returns a value that indicates which button the user clicked.

 
TIP: Use the Docklight-specific DL.MsgBox2 method for a message box that always appears on the same screen as the Docklight Scripting main window. Or see the DL.SetUserOutput function on how to create an additional user output area and display extra user information.

 

Syntax

 

result = MsgBox (prompt[, buttons][, title][, xpos][, ypos][, helpfile, context])
 

Part

Description

prompt

Required. Same as InputBox Function above.

buttons

Optional, common values are a combination (sum) of the below constants:

 

Constant                Value        Description

vbOKOnly                0        OK button only (default)

vbOKCancel                1        OK and Cancel buttons

vbAbortRetryIgnore        2        Abort, Retry, and Ignore buttons

vbYesNoCancel        3        Yes, No, and Cancel buttons

vbYesNo                4        Yes and No buttons

vbRetryCancel                5        Retry and Cancel buttons

vbCritical                16        Critical message

vbQuestion                32        Warning query

vbExclamation                48        Warning message

vbInformation                64        Information message

vbDefaultButton1        0        First button is default (default)

vbDefaultButton2        256        Second button is default

vbDefaultButton3        512        Third button is default

 

TIP: For a full list of all constants available, see the Microsoft VBA documentation for MsgBox.

title

Optional. Same as InputBox Function above.

xpos, ypos, helpfile, context

Optional. Same as InputBox Function above.

result

Returns the user action:

 

Constant        Value        Description

vbOK                1        OK button pressed

vbCancel        2        Cancel button pressed

vbAbort        3        Abort button pressed

vbRetry        4        Retry button pressed

vbIgnore        5        Ignore button pressed

vbYes                6        Yes button pressed

vbNo                7        No button pressed

 

'Example MsgBox Function

result = MsgBox("Run this test?", 3, "My Title")

If result = 6 Then 

 DL.AddComment "Yes button pressed"

ElseIf result = 7 Then 

 DL.AddComment "No button pressed"

Else

 DL.AddComment "Canceled"

End If

 

 

ScriptEngine Function

 

Returns a string representing the scripting language in use.

Use the following script example to get the complete description of script language and version number.  

 

'Example using the ScriptEngine Function

DL.AddComment GetScriptEngineInfo

 

Function GetScriptEngineInfo

  Dim s

   s = "" ' Build string with necessary info.

   s = ScriptEngine & " Version "

   s = s & ScriptEngineMajorVersion & "."

   s = s & ScriptEngineMinorVersion & "."

   s = s & ScriptEngineBuildVersion

   GetScriptEngineInfo = s ' Return the results.

End Function