
- Home
- Magazine
- Conference & Seminars
- News
- Archives
- Forums
- Store
- Directory
- Editorial
- Advertising
- User/Login
- Contact



Assistants are a key part of the Mac OS 8 help system. An assistant makes an application's features easier to use and more readily accessible. In anticipation of Mac OS 8, this article will show you how to build Mac OS 8-style assistants into your System 7 applications, from design to implementation. We illustrate this with a sample assistant developed for the Internet Configuration System.
Developers are constantly pursuing two goals that seem to be at cross-purposes: making applications more powerful and making them easier to use. All too often, power brings complexity, when in fact power can be used to simplify things for the user. Assistants can make the powerful features you're building into your applications easier to access and handle.
An assistant offers the user an alternate interface. It focuses on a specific activity that the average user is likely to want to do and frames the application's functionality to support that activity. The defining aspect of an assistant is the interview, in which the user is asked to supply information about preferences and typical activities accomplished with the application.
Although assistants can be implemented under System 7, they'll be able to do more using Mac OS 8 technologies. In this article, we talk about what Mac OS 8 assistants are and give some general guidelines for designing an interview. We also provide an example of how to implement an interview in System 7. Our sample assistant helps users with the Internet Configuration System (Internet Config), a utility for setting preferences for Internet applications. Internet Config is described in detail in the article "Implementing Shared Internet Preferences With Internet Config" in develop Issue 23. The source code for the Internet Setup Assistant is included on this issue's CD.
At first glance, assistants might seem to resemble Microsoft's wizards. Currently, however, there are differences between them. Wizards don't make reasonable assumptions based on user context and user activity. Instead of filtering out options that aren't applicable, they present all options. While assistants provide an alternate interface to an application or set of applications, wizards might be the only user interface to a task, and they aren't capable of pulling together elements from other places in the interface. Wizards also can't schedule tasks for later execution.

Figure 1. A typical assistant interview window
With Internet Config, the user can create a single file that stores preferences and settings for all Internet services. As long as an e-mail program, Web browser, or other Internet application uses the Internet Config preferences file, the user doesn't have to reenter Internet preferences for each program.
Internet Config's central location for user interaction is the window shown in Figure 2. Clicking each button in the main window brings up a window in which the user enters information and sets preferences.

Figure 2. Internet Config's main window
Internet Config enables users to store a broad range of preferences, from e-mail addresses to file conversion formats. Most users never need to set many of these preferences, but the dedicated Internet habitue probably finds them all useful. Internet Config risks being overwhelming for the sake of completeness -- a perfect opportunity for an assistant. Our assistant makes Internet Config easier to use by helping the user create a preferences file that stores only the preferences that are most commonly set.
Assistants should be made available from wherever they make sense. For the Internet Setup Assistant, it would be helpful to add an Assist Me button to the main Internet Config window and an Internet Setup Assistant command to the Help menu. Application programs that use Internet Config could have a similar button in logical places in their user interfaces. In addition, the Internet Setup Assistant could be automatically displayed the first time the user launches Internet Config.

Figure 3. The Internet Setup Assistant introduction
The next panel, titled "Personal Information," was shown earlier in Figure 1. This panel poses two questions that are easy to answer: it asks for the user's name (filling in a default supplied by the file sharing setup) and company or organization. This starts the interview off smoothly while still obtaining necessary information.
The remaining interview panels that ask questions are listed below (in the order they appear) and are shown in Figure 4. Note that for a few of the questions, the assistant provides some information because the questions might be too difficult for some users to answer. The goal is to keep the interview self-contained, so that the user doesn't need to go to Apple Guide or a manual to figure out what to do.

Figure 4. Internet Setup Assistant interview questions
Finally, when the assistant has asked all the questions, it presents the conclusion panel (Figure 5). The user can see more details by clicking the Show Details button (which then changes to Hide Details); the assistant shows the information it will use in creating the Internet preferences file (name, organization, e-mail address, and so on), summarizing the user's interview responses.

Figure 5. The Internet Setup Assistant conclusion
That's it: ten questions in seven panels, plus an introduction and a conclusion.
Our assistant is based on a simple framework that provides a lightweight object-oriented coating on top of the Macinosh Toolbox. For example, we have classes that provide an object-oriented layer on top of Point (CPoint), Rect (CRect), WindowPtr (CWindow), DialogPtr (CDialog), and so on. We also have a simple application shell, TApplication. Those files are grouped in the framework folder.
The classes aren't dependent on each other, so you can use them easily in your existing application. You can create an assistant dialog by using an object of a TAssistant subclass and sending it the appropriate events. Your usual framework can still be used for handling your event loop and your application's windows. To implement the appearance of assistants using your own framework, check out the TAssistant class to see how we've done it.
The interview is presented in a dialog by a TAssistant object. The class TAssistant is a subclass of CMultiDialog, which allows you to have subdialogs that can be switched in and out as needed. You could use a similar technique to switch among multiple panels in a preferences dialog. Our implementation uses the ShortenDITL and AppendDITL routines, as shown in Listing 1. For another way to change panels, see the article "Multipane Dialogs" in develop Issue 23.
void CMultiDialog::SetSubDialog(SInt16 subDialogID)
{
if (GetWindowRef() == NULL)
CreateWindow();
if (GetSubDialog() != subDialogID) {
// Save parameters in current panel.
for (int i = 0; i < kDialogParametersCount; i++) {
if (fParameters[i].dialogItem != 0)
GetItemText(fParameters[i].dialogItem,
fParameters[i].value);
}
// Remove items from current dialog.
if (fSubDialogID > 0)
ShortenDITL(GetDialogRef(),
CountDITL(GetDialogRef()) - fCommonItems);
fSubDialogID = subDialogID;
{
// Add new dialog items to the dialog.
Handle items = GetResource('DITL', GetSubDialog());
assert(items != NULL);
AppendDITL(GetDialogRef(), items, overlayDITL);
ReleaseResource(items);
}
// Prepare the items in the dialog.
DoPrepareDialog();
}
}
void CDialog::SubstituteParameters(void)
{
LazyHandle substitutionText, itemText;
// Reset the association between parameters and dialog items.
for (int i = 0; i < kDialogParametersCount; i++)
fParameters[i].dialogItem = 0;
// Loop through all dialog items.
for (int item = 1, itemCount = CountDITL(GetDialogRef());
item <= itemCount; item++) {
SInt16 itemType = GetItemType(item);
// If it's a static or editable text item...
if (itemType == kEditTextDialogItem ||
itemType == kStaticTextDialogItem) {
Boolean itemTextChanged = false;
// Copy the text to a handle.
Str255 itemTextString;
GetItemText(item, itemTextString);
itemText.Set(&itemTextString[1], itemTextString[0]);
// Loop through the parameters.
for (int j = 0; j < kDialogParametersCount; j++) {
// If the parameter is used as a nonempty key...
if (fParameters[j].key[0] != 0) {
if (itemType == kEditTextDialogItem &&
::IdenticalString (itemTextString,
fParameters[j].key, NULL) == 0) {
// If the edit field contains only the key,
// associate the item index with the parameter. The
// parameter value is updated when the text
// changes.
fParameters[j].dialogItem = item;
}
{
// Replace the key with the parameter value, using
// the Script Manager.
substitutionText.Set(&fParameters[j].value[1],
fParameters[j].value[0]);
if (::ReplaceText(itemText, substitutionText,
fParameters[j].key) > 0)
itemTextChanged = true;
}
}
}
if (itemTextChanged) {
// The item text has changed. Put the modified text back
// in the dialog item.
Str255 s;
s[0] = itemText.GetSize();
BlockMoveData(*itemText, &s[1], s[0]);
SetItemText(item, s);
}
}
}
}
When the user has entered all the information we ask for and clicked the Go Ahead button, we again use Internet Config, this time to set the user's preferences. The CInternetConfig class provides a C++ wrapper to the Internet Config API. See the details in the source code.
This sample assistant, though a relatively unambitious demonstration, should start you thinking about how to design and develop assistants for your own applications. Nothing is quite as powerful as simplicity.
JOSE ARCELLANA (arcellan@apple.com) is a human interface designer working on Mac OS 8 assistants, Apple Guide, and related technologies. He lives a rich analog life with his wife, their four-year-old child, and a yellow Labrador retriever in an 86-year-old Craftsman bungalow in Oakland. The house has lots of books, four guitars, and no television.*
ARNO GOURDOL (arno@apple.com) has been spotted on top of various San Francisco Bay Area chthonic protrusions with a merry group of Moof hikers in a futile attempt to cure his acrophobia. He has recently been engrossed by the Epic of Gilgamesh and would love to find someone with a good copy of the twelve tablets. In his spare time, Arno is the technical lead of the Mac OS 8 assistance and related technologies team.*
Thanks to our technical reviewers Deeje Cooley, Winston Hendrickson, Rick Mann, Jim Palmer, and Jim Rodden.*




