beautypg.com

Displaying online help from the assistant 18 – Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 665

background image

C H A P T E R 1 8

Intelligent Assistant

Using the Assistant

18-19

preConditions

array is related to the first element of the

signature

array,

the second element of the

preConditions

array is related to the second

element of the

signature

array, and so on. For more information, see the

section “The Signature and PreConditions Slots” (page 18-10).

9. Place the value

nil

in the score slot. This slot is used internally by the Assistant.

Sample Task Template

18

The following code fragment is an example of a task template. This template might
be used to implement an action in a home banking application:

payTemplate := {

value:

"Pay Template",

// name of this template

isa:

'task_template,

// must use this value

primary_act: myPayAction,

// primary action

PostParse:

func () begin … end, // PostParse method

// required templates

signature:

[myPayAction, myWho, myAmount, myWhen],

// slots to create as required templates are matched

preConditions: ['action, 'name, 'amount, 'when],

score:

nil

// for internal use

}

Registering and Unregistering the Task Template

18

To register your task template, call the

RegTaskTemplate

function from your

application part’s

InstallScript

function. When the task template is registered

successfully, the value returned by

RegTaskTemplate

is a reference to the task

frame. You need to save a reference to the value returned by this function, because
you’ll need that value later to unregister the task template. If

RegTaskTemplate

returns

nil

, the template was not registered successfully.

To unregister your task template, call the

UnRegTaskTemplate

function, passing

as its argument the result that was returned by

RegTaskTemplate

when you first

registered the task template. It is recommended that you call the

UnRegTaskTemplate

function from your application part’s

RemoveScript

method.

Displaying Online Help From the Assistant

18

Application help takes the form of a help book created with Newton Book Maker.
You need to take the following steps to open a help book from the Assistant:

1. In your application’s base view, define a

viewHelpTopic

slot. The value of

this slot is a string that is the name of a topic in the help book to be opened.