Apple Newton Programmer’s Newton 2.0 (for Newton 2.0) User Manual

Page 846

Advertising
background image

C H A P T E R 2 3

Endpoint Interface

23-18

Using the Endpoint Interface

Handling Normal Termination of Input

23

The

InputScript

message is sent to the input spec frame when one of the

termination conditions is met. You define the

InputScript

method in the input

spec frame.

The received data is passed as a parameter to the

InputScript

method. Another

parameter describes the specific condition that caused the input to terminate, in
case you had specified more than one in the input spec.

When the

InputScript

method returns, the system automatically posts another

receive request for you using the same input spec as the last one. You can prevent
this by calling

SetInputSpec

within the

InputScript

method. In the

SetInputSpec

method, you can set a different input spec, or you can prevent a

new input spec from being posted by setting the

inputSpec

parameter to

nil

. Note

that while the input spec is

nil

, incoming data may be lost.

Periodically Sampling Incoming Data

23

You can sample the incoming data without meeting any of the termination
conditions by specifying a

PartialScript

method in the input spec. The system

sends the

PartialScript

message to the input spec frame periodically, at the

frequency you define in the

partialFrequency

slot in the input spec, as long as

there are one or more bytes of data in the input buffer. The system passes to the

PartialScript

method all of the data currently in the input buffer, but the data

is not removed from the input buffer. If you want to remove this data from the input
buffer, you can call the

FlushPartial

method.

Note that the sending of

PartialScript

messages is controlled by system idle

events and is in no way triggered by receive request completions. The current input
spec remains in effect after the

PartialScript

method returns.

You typically would use a

PartialScript

method to detect abnormal or

out-of-band data not found by any of the usual input termination conditions.

You can specify

PartialScript

methods only for those input data forms that

allow termination conditions —specifically, the

'string

and

'bytes

data forms.

To use the

PartialScript

method, you must also include the

partialFrequency

slot in the input spec. The

partialFrequency

slot

specifies the frequency, in milliseconds, at which the input data buffer should be
checked. If new data exists in the buffer, the

PartialScript

message is sent to

the input spec frame.

Advertising