The documentation of HomeSite 4.0's object model in beta 2 lacked any information about the InputBox and MessageBox methods, so I began to play with them. Here's what I've come up with so far.
InputBox
The InputBox function is quite simple. The syntax is as follows:
somevar = Application.InputBox(Title As String, Prompt As String, DefaultValue As String)
Now, you can call this method without assigning it to a variable, but then it doesn't do you much good. So, in a script, you'd most likely see something like this:
Javascript:
function Main () {
var app = Application;
var strSomeText = app.InputBox("My Script Title", "Please enter some text:", "Some text");
// now do something with the text
}
VBScript:
Sub Main
dim app = Application
dim strSomeText
strSomeText = app.InputBox("My Script Title", "Please enter some text:", "Some text");
' now do something with the text
MessageBox
Ah, now the fun begins! The MessageBox method is much richer; this is where you can get a little fancier. The basic syntax of the MessageBox method is as follows:
somevar = Application.MessageBox(Prompt As String, Title As String, Buttons As Integer)
This method can also be called without assigning it to a variable, just as a notification. Prompt and String are obvious, but Buttons aren't.
If you're familiar with Visual Basic, you'll know that the buttons displayed on a dialog can be modified by changing a number to indicate which buttons should be on the dialog. HomeSite does the same thing. Here are the what the different values for Buttons do:
Integers 0-15 belong to a group: they display no icon on the message box window.
0 = OK button only
1 = OK & Cancel buttons
2 = Abort, Retry, & Ignore buttons
3 = Yes, No & Cancel buttons
4 = Yes & No buttons
5 = Retry & Cancel buttons
6 = Help button - Note: there is currently no way to close the message box window that pops up other than closing HomeSite.
7 = no buttons - Note: same as for 6
8 = Cancel & Help buttons - Note: clicking the Help button currently does nothing on any message box on which it appears.
9, 11, 13, 15 = all the same as 7: no buttons & no way to close the message box window.
10 = OK, Cancel, & Help buttons
12 = Help, OK, Cancel, and Help buttons (yes, Help is on there twice!)
14 = Ok, Cancel, Help, Abort, and Retry buttons (all of the available buttons)
Integers 16-31 belong to a group: they display the STOP icon on the message box window.
All the buttons are the same as for the lower group; just add 16, so 16 = OK, 17 = OK & Cancel, and so forth, but all with the STOP icon.
Integers 32-47 follow the same pattern; they display the Question icon.
Integers 48-53 display the Exclamation icon, and integers 64-79 display the Information icon.
Integers above 79 all show no icon again, like the first grouping.
In addition, the button that the user clicks returns a unique value. They are as follows:
OK = 1
Cancel = 2
Abort = 3
Retry = 4
Ignore = 5
Yes = 6
No = 7
(Note again that the Help button does nothing.)
I recommend that you keep a script handy with a set of constants defined that are easier to remember than all these numbers. Then cut and paste the values that you need into your script. Visual Basic uses a set of constant for this purpose, labeled, for example, vbYesNo, or vbOKCancel. For my purposes, I find a similar scheme useful:
hsOKValue (this is the value for the button click) = 1
hsCancel = 2
hsAbort = 3
hsRetry = 4
and so forth...
I do the same with the button image values:
hsOK = 0
hsOKCancel = 1
...
hsOKStop = 16
hsOKCancelStop = 17
...
hsOKQuestion = 32
hsOKCancelQuestion = 33
and so forth...
It would be great if HomeSite could expose some constants like these to the scripting engine (but I'm not sure if that's possible).
Good luck and happy scripting!