beautypg.com

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

Page 845

background image

C H A P T E R 2 3

Endpoint Interface

Using the Endpoint Interface

23-17

slot in the input spec. The

filter

slot is a frame containing two slots,

byteProxy

and

sevenBit

, which allow you to perform two different kinds of processing.

The

byteProxy

slot allows you to identify one or more characters or bytes in the

input stream to be replaced by zero or one characters. You may, for instance,
replace null characters (

0x00

) with spaces (

0x20

). Note that if your input data

form is set to

'string

, you are encouraged to use this slot. Otherwise, null

characters embedded in your string may prematurely terminate that string.
(Remember, NewtonScript strings are null-terminated.)

The

byteProxy

slot contains an array of one or more frames. Each frame must

have a

byte

slot, identifying the single-byte character or byte to be replaced, and a

proxy

slot, identifying the single-byte character or byte to be used instead. The

proxy

slot can also be

nil

, meaning that the original byte is to be removed

completely from the input stream.

Note

Note that the system executes byte-by-byte comparisons and
swaps between the bytes in the input stream and the replacements
in the

proxy

slot. To facilitate this process, the values in the

byte

and

proxy

slots are converted to a byte format to speed the

comparison and swap. Internally, single characters are converted
to single bytes using the translation table specified in the endpoint

encoding

slot. Numbers are converted to single bytes. If a

number has significant digits beyond the high-order byte, they
will be dropped during the comparison and swap.

You can also specify the

sevenBit

slot in the

filter

frame. Set this slot to

true

to specify that the high-order bit of every incoming byte be stripped (“zeroed

out”). This is a convenient feature if you plan to communicate over links
(particularly private European carriers) that spuriously set the high-order bit.

Specifying Receive Options

23

You can also set communication tool options associated with the receive request.
To do this, specify an option frame or an array of option frames in the

rcvOptions

slot in the input spec. The options are set when the input spec is posted by the

SetInputSpec

method. The processed options are returned in the

options

parameter passed to the

InputScript

method.

Note that the options are used only once. If your

InputScript

method is called,

for example, and it returns expecting the input spec to remain active, the options
are not reposted. To explicitly reset the options in this example, you must call

SetInputSpec

within your

InputScript

method.