When you create a script named xyz, Doc-To-Help automatically creates a subroutine declaration for it, resulting in the following VBScript code:
Sub xyz()
' Body of xyz script
End Sub
This has the following implications:
• Script names must be legal procedure names in VBScript. That is, they must start with a letter and contain only letters, numbers, and underscores.
• You cannot define other subroutines or functions within the body of a Doc-To-Help non-global script, as VBScript does not support nested procedures.
Function pi() ' Not a valid Doc-To-Help script
pi = 3.14159
End Function
• You can use the Exit Sub statement to exit a script.
If expression Then
MsgBox "Exiting script"
Exit Sub
End If
• You can use the Call statement to execute another script.
Call xyz
xyz ' Call keyword is optional
Unlike other Doc-To-Help objects such as styles, scripts have no properties that you can set in the authoring environment (other than the code itself)
Note: There is one exception to the rule that script names must be legal VBScript procedure names. If a script name starts with a character that is not a letter, Doc-To-Help treats it as a global module. This means that it can contain subroutines and functions that can be called from other scripts. For more information, see Creating a Global Script Module.