You are here: Scripting Techniques > What are Scripts?

What are Scripts?

Doc-To-Help scripts are code modules written in the VBScript. They can be used to modify the behavior of paragraph and character styles during compilation. If you are familiar with event-driven languages such as Visual Basic, you can think of a script as an "event handler" for a style. Just as the Click event is fired when the user clicks a button in a Visual Basic application, a script is executed whenever Doc-To-Help encounters a topic or a hot spot defined by a scripted style.

You can perform the following operations in script code:

      Create top-level and secondary index keywords.

      Create named topic groups.

      Assign index keywords and groups to topics.

      Assign context-sensitive Help IDs to topics.

      Modify the link tags of topics and hot spots.

You can perform all of these operations in Doc-To-Help's authoring environment using techniques outlined elsewhere. If the notion of writing code seems daunting, then you are not required to use scripts at all. However, a simple script can save you many hours of tedious labor. This is especially true in cases where the title of a topic or the text of a hot spot can be split apart or rearranged to yield a textual match or a different focal point for an index entry. For example, given a set of topic titles of the form Adjective Noun, you could write a script to parse the title and associate three index keywords with each topic:

Adjective noun

nouns

nouns, Adjective

Note that you can control both the capitalization and the number (singular or plural) to conform to standard indexing conventions. You can also employ secondary keywords to improve the readability of the index:

Adjective noun

nouns

  Adjective

Suppose further that the topics are organized into several documents, with each document describing the features of a particular Widget. With just a few more lines of code, you could extend the index profile for each topic as follows:

Adjective noun

Adjective noun, of Widget

nouns

nouns, Adjective

nouns, of Widget

Widget

Widget, Adjective noun

Widget, nouns of

If secondary keywords are used, the reader sees:

Adjective noun

  of Widget

nouns

  Adjective

  of Widget

Widget

  Adjective noun

  nouns of

If you have to document hundreds of nouns for dozens of widgets, then maybe writing a script isn't such a crazy idea after all!

More:

Scripts are Subroutines

Scripts Access the Doc-To-Help Object Model

Scripts are Extensions of Styles