beautypg.com

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

Page 834

background image

C H A P T E R 2 3

Endpoint Interface

23-6

About the Endpoint Interface

placeholder or default values, which the system fills in when the data is received.
For more information, see the section “Specifying the Data Form and Target”
beginning on page 23-13.

The data types that can be used in the

typelist

array are identified by these

symbols:

'long

,

'ulong

,

'short

,

'byte

,

'char

,

'unicodechar

,

'boolean

,

'struct

, and

'array

. They are described in detail in “Data Type

Symbols” (Table 20-2 on page 20-3) in Newton Programmer’s Reference.

Note that the

'struct

and

'array

data types are not used alone, but in

conjunction with other elements in a

typelist

array. They modify how the other

elements are treated. The

'struct

data type defines the array as an aggregate

structure of various data types that is padded to a long-word boundary (4 bytes in
the Newton system). Note that the whole structure is padded, not each array
element. You must specify the

'struct

data type in order to include more than

one type of data in the array.

The

'array

data type defines the array as an aggregate array of one or more

elements of a single data type. The

'array

data type is specified as a NewtonScript

array of three items, like this:

['array,

dataTypeSymbol

,

integer

]

Replace the

dataTypeSymbol

with one of the other simple data types. And

integer

is

an integer specifying the number of units of that data type to convert. To convert an
entire string, including the terminator, specify zero for

integer

. A nonzero value

specifies the exact number of units to be converted, independent of a termination
character in the source string.

Here are some examples of how to use the

'array

data type to represent C strings

and Unicode strings in NewtonScript. The first example shows how to convert
between a NewtonScript string of undefined length and a C string (translated
to/from Unicode):

['array, 'char, 0]

This example shows how to convert a four-character NewtonScript string to a C string:

['array, 'char, 4]

This example shows how to convert between a NewtonScript string and a
Unicode string:

['array, 'unicodechar, 0]

The

'template

data form is intended primarily as a means of communicating

with the lower level communication tools in the Newton system. You can use this
data form to communicate with a remote system, however, you must be careful and
know exactly what you are doing to use it for this purpose. Remember that the
lengths of various data types and the byte order may be different in other systems
and may change in future releases of the Newton operating system.