Output Types

Correct Use of Output Modes

Prior to JAWS 6.01, Output Modes (or Output types) were used as a means of controlling information spoken at each verbosity level. With the introduction of Braille Flash Messages in JAWS 6.0, Output Modes are also now used to control which messages are sent as Flash messages to the display. It is thus vital to ensure that correct use of Output Modes is made during scripting to avoid unnecessary Flash messages appearing in Braille. This document outlines the use of Output Modes.

It is very important that correct Output Modes be used not only because of Flash Messages but because JAWS uses the Output Mode in conjunction with all of the JCF options and the Speech and Sounds Scheme in use to determine how text should be spoken. For example, if OT_SPELL is used, JAWS will spell rather than speak the text using the voice alias defined for spelling. Similarly, text spoken using OT_KEYBOARD will honour the current Typing Echo settings. Not all Output Modes are relevant for Braille. Generally, text which is rendered on the display by means of Line or Structured modes does not need to be sent as a Flash Message. For this reason, many of the Output Modes are disabled for Braille altogether. The relevant Output Modes which are configurable for Braille are listed at the end of this document.

::: {#ot_no_disable}

OT_NO_DISABLE

:::

This output Mode should be used very sparingly as messages spoken using it cannot be suppressed and will generate Flash messages.

::: {#ot_help}

OT_HELP

:::

This Output Mode Should be used to speak all Screen Sensitive, Hotkey, Keyboard or other help messages when these messages are not being displayed in the virtual viewer.

::: {#ot_app_start}

OT_APP_START

:::

This Output Mode should only be used to speak messages generated when an application first starts (and only once per JAWS session).

::: {#ot_jaws_message}

OT_JAWS_MESSAGE

:::

This Output Mode should be used to speak messages originating from JAWS, for example when the information is originating from JAWS rather than the application. For example, JAWS for Windows is Ready, JAWS is running in demo mode, or when the user presses a keystroke assigned to a JAWS function, to announce the function name.

::: {#ot_screen_message}

OT_SCREEN_MESSAGE

:::

This Output Mode should be used to speak screen text from application instructions or help messages not considered dialog text. It would typically be spoken via the SayNonHighlightedTextEvent. For example, if a window contains added information about how to interact with the application, but is not essential for interaction with the application. It could be considered supplemental information which the user would perhaps want to hear once but not each time they ran the program. Note that this Output Mode should only be used when the window is automatically spoken. If the user specifically requests the help text via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

OT_CONTROL_GROUP_NAME

This Output Mode should be used to speak the name of a group box surrounding a set of controls. For example, the title of a group of checkboxes. Note that this Output Mode should only be used when the group or a control within the group gains focus or is automatically spoken. If the user specifically requests the control group's title via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

::: {#ot_control_name}

OT_CONTROL_NAME

:::

This Output Mode should be used to speak the prompt of a control. For example, the text to the right of an edit or the label of a button. It should not be used to speak type information nor should it be used to speak the control's contents such as the text in an edit. Note that this Output Mode should only be used when the control gains focus or is automatically spoken. If the user specifically requests the control's prompt via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

::: {#ot_control_type}

OT_CONTROL_TYPE

:::

This Output Mode should be used to speak type information about the focused control. For example, if scripts are written to support a custom control, the description of the control should be spoken with this Mode. An example might be a new Grid control. The word Grid would be spoken using this Output Mode. Note that this Output Mode should only be used when the control is automatically spoken. If the user specifically requests the control's type via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

::: {#ot_dialog_name}

OT_DIALOG_NAME

:::

This Output Mode should only be used to speak the title of a dialog (when a dialog is invoked by the user or application). It should not be used when the user specifically asks for the dialog's title.

::: {#ot_dialog_text}

OT_DIALOG_TEXT

:::

This Output Mode should be used to speak descriptive dialog text essential for correct use of the dialog controls. dialog text is text not part of a control's prompt within the bounds of the current dialog. Note that this Output Mode should only be used when the dialog is automatically spoken. If the user specifically requests the dialog text via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

::: {#ot_document_name}

OT_DOCUMENT_NAME

:::

This Output Mode should be used to speak a document's title when a document window gains focus. If the user specifically requests the document title via a keystroke, the OT_USER_REQUESTED_INFORMATION Output Mode should be used instead.

::: {#ot_item_state}

OT_ITEM_STATE

:::

This Output Mode should be used to speak the state of a control, for example, checked or not checked. It should only be used when the state is toggled or changed, not when the state is specifically requested by the user via a keystroke.

::: {#ot_position}

OT_POSITION

OT_POSITION :::

This Output Mode should be used to speak the position of an item relative to others in its container. For example, the current item in a list, the current node in a tree. It should only be used when the position information is spoken automatically, not when it is specifically requested by the user via a keystroke.

::: {#ot_error}

OT_ERROR

:::

This Output Mode should be used to speak error messages generated as a result of the user performing an inappropriate action. For example, trying to invoke the ListOfLinks in a context where no links maybe listed. It is for JAWS user errors, not application errors.

::: {#ot_tool_tip}

OT_TOOL_TIP

:::

This Output Mode should be used to speak tooltips generated by the operating system or application. A tooltip is a small bubble which appears as a result of moving the mouse pointer over a graphical object.

::: {#ot_help_balloon}

OT_HELP_BALLOON

:::

This Output Mode is used to speak Help Balloons generated by the Aplication or operating system. a Help Balloon differs from a tooltip in that it is generated as a result of user action or when the application or operating system wants to inform the user without the use of a dialog.

::: {#ot_status}

OT_STATUS

:::

This Output Mode is used to speak status messages, for example, when the user presses a keystroke which toggles a JAWS setting on or off. The state of the setting is spoken using this output mode whereas the setting's name itself should be spoken using OT_JAWS_MESSAGE.

::: {#ot_smart_help}

OT_SMART_HELP

:::

This Output Mode should be used for supplemental help given by JAWS for efficient use of an application (text which is not on screen). This does not include Screen Sensitive, Keyboard or Hotkey help, these should be spoken using OT_HELP.

::: {#ot_select}

OT_SELECT

:::

This Output Mode should be used to speak the message preceding or following the act of selecting text in an editor.

::: {#ot_tutor}

OT_TUTOR

:::

This Output Mode should be used to speak tutor information when a control gains focus, for example, "Press Enter to activate" or "Type in text".

::: {#ot_access_key}

OT_ACCESS_KEY

:::

This Output Mode should be used to speak the Access Key (underlined character) in a menu or control's prompt. An access key represents the key to press as a short cut to invoking the action described by the prompt of the control. For example, in an Edit Menu, the E maybe underlined which means that the user needs to press E to select that item directly without having to arrow to that item and press Enter.

::: {#ot_user_requested_information}

OT_USER_REQUESTED_INFORMATION

:::

This Output Mode should be used whenever a user requests information to be spoken via a keystroke. For example, if the user presses JAWSKEY + F12 to hear the time, JAWSKEY + T for the window title, etc.

Special Uses

The following Output Modes have special uses:

::: {#ot_blank_line_count}

OT_BLANK_LINE_COUNT

:::

Use this when a script is controlling SayAll to speak the number of blank lines.

::: {#ot_user_buffer}

OT_USER_BUFFER

:::

Use this to redirect the text to the virtual viewer rather than speaking it directly.

::: {#ot_phonetic_char}

OT_PHONETIC_CHAR

OT_PHONETIC_CHAR :::

Use this to cause the string to be expanded to its phonetic rendering. For example, say("a", OT_PHONETIC_CHAR) would say "alpha". If the string contains more than one character, the string will be spelled phonetically.

::: {#ot_braille_message}

OT_BRAILLE_MESSAGE

:::

This Output Mode should be used for messages specifically for Braille which won't ever be spoken. This could be used for displaying a dot pattern which represents some graphical layout information which has no speech equivalent.

::: {#ot_highlighted_screen_text-and-ot_nonhighlighted_screen_text}

OT_HIGHLIGHTED_SCREEN_TEXT and OT_NONHIGHLIGHTED_SCREEN_TEXT

:::

These two Output Modes should be used to speak text from the SayHighlightedText and SayNonHighlightedText functions.

::: {#ot_keyboard}

OT_KEYBOARD

:::

This Output Mode should be used to speak key labels as keys are pressed on either the main keyboard or Braille keyboard.

::: {#ot_spell}

OT_SPELL

:::

When text is spoken using this Output Mode, it is spelled rather than spoken. If a voice alias has been chosen for spelled text, this voice alias will be used as the text is spelled.

::: {#ot_sayall}

OT_SAYALL

:::

This Output Mode should be used when scripts are used to control a SayAll during the speaking of the units of text.

::: {#internal-output-modes}

Internal Output Modes

:::

The following Output Modes are used internally by JAWS and should only be used when the intent is to override default JAWS behaviour in an equivalent situation. For example, the SayWord function is overridden, the text spoken by that function should use OT_WORD. etc. Another example might be a function which automatically speaks a graphic when it appears on the screen, OT_GRAPHIC should be used:

  • OT_STRING

  • OT_GRAPHIC

  • OT_CHAR

  • OT_WORD

  • OT_FIELD

  • OT_CHUNK

  • OT_LINE

  • OT_TEXT

  • OT_FONT

  • OT_CURSOR.

::: {#braille-specific-output-modes}

Braille Specific Output Modes

:::

The Output Modes which are relevant to Braille are as follows:

  • OT_NO_DISABLE

  • OT_HELP

  • OT_APP_START

  • OT_JAWS_MESSAGE

  • OT_ERROR

  • OT_TOOL_TIP

  • OT_STATUS

  • OT_SMART_HELP

  • OT_TUTOR

  • OT_HELP_BALLOON

  • OT_BRAILLE_MESSAGE.

The only one of this list which is not configurable is OT_NO_DISABLE.

The JAWS Message Format

The JAWS message format allows you to create messages just as if you were typing the text of the message in a text editor or word processor. You no longer have to use string concatenation to produce speech output. The message format also gives you the ability to dynamically add information to your messages through the use of embedded place holders.

Using the message format, someone who is not a programmer can also edit the text of existing messages. You can type any character within the body of your message. JAWS can then speak the text or display the text of your message in the virtual viewer with a single function call to either the SayMessage or SayFormattedMessage function.

Although you can declare messages using the message format within a script source file (.jss), it is best to declare those messages within a script message file (.jsm). You then include the message file within your script file using the "Include" statement discussed earlier.

Message Format

The JAWS message format consists of several key words:

  • Messages

  • @MsgName

  • @@

  • EndMessages

::: {#messages-keyword}

Messages

:::

The Messages keyword indicates the beginning of the message block. It tells the compiler that everything between this line and the EndMessages line is written in the message format. You can place as many messages as you wish within a message block. You should only place this keyword once at the top of your message file following any comments. You do not need to include the Messages keyword for every individual message you create.

::: {#msgname}

@MsgName

:::

The @MsgName statement indicates the beginning of an individual message. The at symbol ("@") indicates the beginning of an individual message. The "MsgName" portion of this statement is the actual name of the message that you designate. You should follow the same rules for naming messages as you do variables, scripts and user-defined functions. You should use no spaces, capitalize the first letter of each word and no punctuation except for the underline character ("_"). You will use the string of text less the at symbol ("@"), to refer to this message in your scripts and functions that speak the message.

All text following the "@MsgName" statement is part of the message body. All characters typed in the message body are literal, meaning that all characters are part of the individual message. You no longer need to use the backslash ("") character in front of any special characters that previously required it for translation. When you want a new line in your message, you can insert it by pressing ENTER.

You can also use placeholders within the body of your message. These placeholders give you the ability to place information gathered during script or function execution into your message. You can use up to nine placeholders within the body of the message. To add a placeholder in the message, you precede the number of the placeholder with the percent sign ("%").

In addition to placeholders, you can use the KeyFor function to display keystrokes within the body of your message. This functionality is available only when displaying messages within the virtual viewer. When the KeyFor function is used, the keystroke is shown in the virtual viewer as a link. The keystroke can be activated by navigating to the link and pressing ENTER.

To add the KeyFor() function to the body of your message, you must precede the name of the function with the percent sign (%). This indicates the point in your message in which JAWS places the desired keystroke. The KeyFor function requires a single parameter: the name of the script for which the keystroke will be displayed. To add the KeyFor function to the body of any message, use the following syntax:

::: {#statement}

@@ Statement

:::

The "@@" statement indicates the end of an individual message. Each @MsgName must be followed by the @@ statement. There are no spaces between the 2 @ symbols.

::: {#endmessages}

EndMessages

:::

The EndMessages key word indicates the end of the Messages block. Each Messages statement must have a corresponding EndMessages statement. You only need to include this key word once in your message file and usually at the bottom of the file.

::: {#example-message-formats}

Example Message Formats

:::

Messages
@MsgTest
This is a test message.
Note that the text is formatted as you would type it or see it in a dialog box.
@@
EndMessages

The above example contains only one individual message within the message block.

Messages
@MsgTest
This is a test message.
Note that the text is formatted, as you would type it or see it in a dialog box.
@@
@MsgTest2
This is a second message.
Note that multiple Messages can be contained within the message block.
@@
EndMessages

The above example contains two individual messages.

You can find many of these messages in the file Common.jsm. It is recommended you include this file in all your script files, as all messages and string constants contained in it begin with the letter "c" or "sc" to avoid conflicts with your existing definitions. The Default.jsm file is still included to support any legacy code that uses the old JAWS system. If you need to copy some of your own scripts into the default file, just include the default.jsm file if you are using constants from there.

The FormatString Function

The FormatString function gives you the ability to dynamically replace text within the individual message using placeholders. As stated earlier, the placeholder uses the percent sign (%) followed by a number. These placeholders can be placed throughout the individual message.

The FormatString function formats the string containing the message and replaces any placeholders with strings of text. the FormatString function then returns the formatted string to the calling script or function. The syntax of the FormatString function is as follows:

Let sMessage = FormatString (MsgName, sString1, sString2, sString3)

The MsgName variable is the individual message declared within the messages block. The parameters listed next are used to replace their respective placeholders within the message.

When you use the FormatString function and do not use all parameters, you must be sure to remove all commas following the last actual parameter used. For example, if you are using the FormatString function to add text to three place holders within a message called MsgText, the line inserted in your script by the Insert Function dialog looks like the following:

Let sMessage = FormatString (MsgText, sText1, sText2, sText3, , , , , , , )

If you use the arrow keys to review the line above, you will notice seven pairs of commas and spaces between the sText3 parameter and the right parenthesis. To ensure no errors are encountered at the time you try to compile the script containing this statement, you must remove the seven pairs of commas and spaces. Failure to do so will result in a "incorrect parameter format" error message when you try to compile the script or function containing the line above.

Let sMessage = FormatString (MsgText, sText1, sText2, sText3) ; removed extra commas and spaces

The number of comma and space pairs may vary based on the number of parameters used to format the message referenced in parameter one. :::

{#formatstring-examples} ### FormatString Examples: :::

The following examples illustrate the use of the FormatString function within a basic "Hello World" script.

::: {#test.jsm}

Test.jsm

:::

; test file containing message statements
Messages
; For msgHello, %1= the first name, %2 = The Last Name
@msgHello
HELLO WORLD! My name is %1 %2.
@@
EndMessages

::: {#test.jss}

Test.jss

:::

; test file To demonstrate the Use of the message format and FormatString Function
Include "HjConst.jsh"; default constants
Include "common.jsm"; default message file
Include "test.jsm"; test message file created above

Script HelloWorld ()
Var
    String sMessage
Let sMessage = FormatString (msgHello, "John", "  "," Doe")
SayFormattedMessage (OT_MESSAGE, sMessage)
EndScript

The spoken output from the above script is:

::: leftbar "HELLO WORLD! My name is John Doe" :::

The SayFormattedMessage Function

In the previous example showing the use of the FormatString function, the SayFormattedMessage function is used to output the text to the synthesizer. The benefit of using the SayFormattedMessage function is that it does a final format of the message in order to account for the %KeyFor() placeholder. The SayFormattedMessage function also gives you the ability to use short and long messages. This added functionality lets you account for the message length option in the Verbosity Options section of the Configuration Manager. You can choose to use short or long messages depending on your verbosity setting and preference.

The SayFormattedMessage function is called using the following syntax:

SayFormattedMessage (OutputMode Constant, LongMessage, ShortMessage)

If you are not using both short and long messages, then you will only need the output mode and long message parameters.

Creating and Speaking Messages Exercises

The following exercises give you practice in creating messages. You will also use the FormatString and SayFormattedMessage built-in functions in these exercises.

Creating a Message File and Adding Messages

The objective of this exercise is to give you practice creating a new message file and adding messages to the file. You will use Notepad for the active application. You will add two messages to the notepad.jsm file. After you have created the messages, you will create a script that speaks those messages.

  1. Activate Notepad from your Start Menu | Accessories group.

  2. From within Notepad, press JAWSKEY + F2 to activate the Run JAWS Managers dialog. Press S followed by ENTER to start the Script Manager.

  3. You need to create a message file for Notepad as it does not have a message file by default. Press CONTROL + N to activate the New File dialog. You are placed in the New list box. The list box contains five entries for creating files. You can use this list box to create a new source file, header file, documentation file, message file, or key map file.

  4. Press M. to select the Messages file (jsm) list item followed by ENTER to create the new message file. When the New File dialog closes, your insertion point is placed in a new untitled message file.

  5. Press CONTROL + S to save the file. This action causes the Script Manager to display the Save As dialog. The focus is in the File Name edit box. Give the new file the name of Notepad. You do not need to include the file extension as the script Manager does that automatically for you.

  6. After the Save As dialog closes, press JAWSKEY + T to read the title bar of the Script Manager. Did you hear the file name of Notepad.jsm?

    When you create script message or header files, give them the same name as the executable file name for the application. This makes it easier for you to locate the message file for a given application should you decide to share the file with someone else. If you are creating a generic message or header file, one not tied to a specific application, you can give it any name you want

  7. You are now ready to add a comment to the top of the file along with the key word used to indicate the beginning of your messages block. Type the following text into your message file:

    ; Message file For Notepad
    Messages
    
  8. Next, you need to add a long message to the message file. If the insertion point is still on the line containing the key word "messages," press ENTER to create a new blank line. Type the following text:

    @MSGText_L
    This is an example of a long message. This message is only spoken by JAWS when the beginner verbosity setting is in Use.
    @@
    
  9. Press ENTER twice on the line containing the two @ symbols. This will create a blank line to separate your long message from your short message.

  10. The short message is next. Type the following text:

    @MsgText_S
    This is an example of a short message.
    @@
    
  11. Press ENTER once to create a new blank line following your short message. Type the following text: "EndMessages"

  12. Press CONTROL + S to save your message file.

    JAWS does not speak "Compile complete." The Script Manager does not compile message files only script source files.

  13. After following the steps above, you should have the following text in the Notepad message file:

    ; Message file For Notepad
    Messages
    @MSGText_L
    This is an example of a long message. This message is only spoken by JAWS when the beginner verbosity setting is in Use.
    @@
    @MsgText_S
    This is an example of a short message.
    @@
    EndMessages
    
  14. Next, you need to create a script that uses the messages you just created. Press CONTROL + TAB to move back to the Notepad.jss script source file.

    You can have more than one file open in the Script Manager at a time. Press CONTROL + TAB to move between the files.

  15. Press CONTROL + HOME to move to the top of the Notepad script source file. You need to include the new message file. Press DOWN ARROW until you reach the blank line following the include statement for the hjconst.jsh file. Type the following text: "Include 'Notepad.jsm' "

  16. After you have typed the text, press ENTER twice to create a new blank line.

  17. Press CONTROL + END to move the insertion point to the bottom of the script file. Press ENTER twice to create a blank line between the last script in the file and your new script.

  18. Press CONTROL + E to activate the New Script dialog and ENTER the following information in the fields in the dialog:

    1. Script Name: SpeakMessage

    2. Can be Attached to Key: checked

    3. Synopsis: Speaks long and short messages in notepad.

    4. Description: Speaks long and short messages in Notepad using the SayFormattedMessage function.

    5. Category: none

    6. Assign to: CONTROL + 3

  19. After you have entered all the information above, press ENTER to close the dialog.

  20. Press UP ARROW to move to the first blank line in the body of the SpeakMessage script.

  21. Press CONTROL + I to activate the InsertFunction dialog. The focus is placed in the Function Name edit box. Look for the built-in function SayFormattedMessage. When you find the function, press ENTER. JAWS prompts you for the first parameter, output type. Type the following text: "OT_MESSAGE"

  22. Press ENTER. JAWS prompts you for the second parameter, the long message. Type the following text in the Parameter 2 edit box: "MsgText_l"

  23. Press ENTER. JAWS prompts you for the third parameter, the short message. Type the following text in the Parameter 3 edit box: "MsgText_s"

  24. You do not need to ENTER any information for the remaining parameters after the short message name. Press TAB to move to the Finish button and press ENTER to close the InsertFunction dialog. Make sure to remove the extra commas and spaces before the right parenthesis

  25. Press DOWN ARROW to move to the next line. Press DELETE. repeatedly until you have removed all blank lines from the script. After you have completed the previous steps, your script should look like the following:

    Script SpeakMessage ()
    SayFormattedMessage (OT_MESSAGE, MsgText_l, MsgText_S)
    EndScript
    
  26. Press CONTROL + S to compile the Notepad script source file. If you hear JAWS speak, compile complete, switch to Notepad and test your script. If you encountered syntax errors, compare your script to the one shown above. Continue to compile your script until you hear JAWS speak compile complete.

  27. To test your script, use the Adjust JAWS Options dialog to change your verbosity setting from beginner to intermediate to advanced. You can access the Adjust JAWS Options dialog by pressing JAWSKEY + V. After you have opened the Adjust JAWS Options dialog, press U. to move to the User Verbosity option. Press SPACEBAR to cycle through the options. When you have selected the desired option, press ENTER to close the dialog and save the verbosity setting change. Each time you switch the verbosity setting, test your script. JAWS should only speak the long message when you are using the beginner verbosity setting. JAWS should speak the short message when you use either intermediate or advanced verbosity setting.

Additional Practice: Extend your Notepad message file with an additional message and modify your script to choose which message to speak based on context (for example, active window title, selection state, or a user setting). What conditions would you check, and how would you structure the code to keep it maintainable?

Using Placeholders

The objective of this exercise is to give you practice using placeholders in your messages, formatting your messages, and speaking those messages. This exercise should be completed in the Notepad script source and message files. If you do not have Notepad or the Script Manager running, refer to steps 1 and 2 in the previous exercise to get started.

  1. Within the script Manager, press CONTROL + TAB until you reach the notepad.jsm message file.

  2. Press CONTROL + END to move to the bottom of the file.

  3. Press UP ARROW until you reach the line containing "EndMessages." Press HOME. to move the insertion point to the beginning of the line.

  4. Press ENTER twice to create a blank line between the last individual message in the messages block and your new message.

  5. Type the following text in the notepad message file:

    @MsgMyName
    Hello, my name is %1 %2. You can just call me %1.
    @@
    
  6. Press CONTROL + S to save the changes to the Notepad message file.

  7. Press CONTROL + TAB to move to the Notepad script source file, Notepad.jss.

  8. Press CONTROL + END to move to the bottom of the file. Press ENTER twice to create a blank line between your last script and the new script.

  9. Press CONTROL + E to activate the New Script dialog. Type the following information into each control within the dialog:

    1. Script Name: SpeakMyName

    2. Can be Attached to Key: checked

    3. Synopsis: Speaks a message containing my name.

    4. Description: Speaks a message containing my name in Notepad. The message uses placeholders.

    5. Category: none

    6. Assign to: CONTROL + SHIFT + N

  10. After you have filled in all of the fields, press ENTER to close the New Script dialog.

  11. Press UP ARROW to move the insertion point to the first blank line in the body of the script. You need to create a local variable declaration section here. Type the following text:

    Var
        String sMessage
    
  12. After you have typed in the variable declaration statement for sMessage, press ENTER to move the insertion point to a new blank line. Type the following text:

    Let sMessage =
    

    Be sure to type a space after the equals sign. This allows for proper spacing when you insert the next function.

  13. Press CONTROL + I to activate the InsertFunction dialog. You need to find the built-in function, FormatString. Once you have located the function, press ENTER to begin adding the parameters.

  14. The first parameter the function requires is the name of the message that contains the text and placeholders. Type the following text: "MsgMyName"

  15. Press ENTER. JAWS accepts the first parameter and then prompts you for the second parameter.

  16. The second parameter is the information that replaces the first placeholder in your message. Type your first name surrounded in quotation marks, for example "John."

  17. Press ENTER to accept the parameter. JAWS prompts you for the third parameter. This parameter is the information that replaces the second placeholder within your message. Type your last name surrounded by quotation marks. For example, "Doe."

  18. Instead of pressing ENTER to accept this parameter, move to and activate the Finish button. The finish button tells JAWS you are finished entering parameters for the function. After the InsertFunction dialog closes, your insertion point is at the end of the line you just entered. Read the line with JAWSKEY + UPARROW. JAWS should speak the following text: "let sMessage = FormatString (MsgMyName, 'John', 'Doe', , , , , , , , )"

  19. You need to remove all the commas and spaces following the quotation mark following your last name. Press LEFT ARROW until you reach the comma immediately following the quotation mark. Press DELETE. repeatedly to remove all commas and spaces until you reach the right parenthesis. The line should look like the following:

    Let sMessage = FormatString (MsgMyName, "John", "Doe")
    
  20. Press END. to move to the character following the right parenthesis. Press ENTER to complete the line. Your Insertion point is now on a new blank line.

  21. Press CONTROL + I to activate the InsertFunction dialog. You are looking for the built-in function, SayFormattedMessage. Once you have located the function, press ENTER.

  22. JAWS prompts you for the first parameter for the SayFormattedMessage function. This parameter is the output mode. Type the following text: "OT_MESSAGE"

  23. Press ENTER to accept the parameter. JAWS prompts you for the next parameter, the long message.

  24. This parameter is the return value from the call to the FormatString function, sMessage. This is the message that has been formatted with your name replacing the placeholders. Type the following text: "sMessage"

  25. Press ENTER to accept the parameter. JAWS then prompts you for the third parameter. This is the short message. You do not need this parameter or any of the remaining parameters; so, activate the Finish button to close the InsertFunction dialog.

  26. Your Insertion point is at the end of the line. Press JAWSKEY + UPARROW to read the current line. JAWS should speak: "SayFormattedMessage (OT_MESSAGE, sMessage, , , , , , , , , , )"

  27. You need to remove the commas immediately following the sMessage parameter. Press LEFT ARROW until you reach a comma. Press DELETE. until you remove the commas and spaces. The line should now look like the following:

    SayFormattedMessage (OT_MESSAGE, sMessage)
    
  28. Press DOWN ARROW once to move to the next line. If this line is blank, press DELETE. to remove it and any other blank lines.

  29. After following the steps above, your script should look like the following:

    Script SayMyName ()
    Var
    String sMessage
    Let sMessage = FormatString (MsgMyName, "John", "Doe")
    SayFormattedMessage (OT_MESSAGE, sMessage)
    EndScript
    
  30. Press CONTROL + S to compile the Notepad script source file. If you did not hear JAWS speak "Compile Complete," return to your script. Correct the error the Script Manager noted and try compiling your script again. Continue this process until you hear "Compile complete."

    When the Script Manager encounters an error, the line containing the error is highlighted.

  31. Return to Notepad and test your script. Did JAWS speak the message?

Using the SayFormattedMessage Function to Substitute Placeholders

New to JAWS 12 update 1, is the ability to replace placeholder values directly in the SayFormattedMessage function rather than having to use the FormatString function to do so. This eliminates the need for the sMessage variable and the FormatString function. If using this method, the script would look like the following.

Script SayMyName ()
SayFormattedMessage (OT_MESSAGE, MsgMyName, MsgMyName, "John", "Doe")
EndScript

Additional Practice: Refactor your message to support additional placeholders (for example, title, greeting, time of day) and experiment with filling them using both FormatString and direct SayFormattedMessage substitution. Which approach is clearer and less error-prone as messages grow?

Adding An InputBox Function

The objective of this exercise is to modify the script created from exercise 8.2 above. Instead of using quoted strings of text as parameters for the FormatString function, use a built-in function to prompt for the first and last name values. You can use the built-in function, InputBox, to accomplish this task. The function displays a dialog box using the title and prompt you specify. When you type information into the edit box contained in the dialog and activate the Ok button, the function returns the text as a string. The InputBox function uses three parameters:

  1. string of text for the dialog prompt

  2. string of text for the title of the dialog box

  3. variable to contain the text typed in the dialog

You should create two additional local variables. The first variable should store the first name. The second variable should contain the last name. When you have made the modifications to the script, it should look like the following:

Script SpeakMyName ()
Var
    sMessage,
    String sFirstName,
    String sLastName
InputBox ("Enter your first name:", "First Name Entry", sFirstName)
InputBox ("Enter your last name:", "Last Name Entry", sLastName)
Let sMessage = FormatString (MsgMyName, sFirstName, sLastName)
SayFormattedMessage (OT_MESSAGE, sMessage)
EndScript

After you have modified the script, compile the script. When you hear the "Compile complete" message, return to Notepad, and test the script.

Additional Practice: Expand the script to prompt for a middle name and nickname, validate empty input or cancellation, and fall back to sensible defaults. How will you handle user cancellation gracefully while keeping the flow simple?

::: .hint For more information on the InputBox function, open the builtin.jsd script documentation file within the Script Manager. :::

1

Released 2005