C H A P T E R 2 1
Routing Interface
21-26
Using Routing
Sending Items Programmatically
21
Your application can send an item programmatically, using a specific transport or
transport group, without any user intervention. The Action button is not used in this
case. This is done using the global function
Send
.
Here is an example of how to use the
Send
function:
myItem := {
toRef: [nameRefObject, ...], // array of fax name refs
title: "The Subject", // title of item
body: {class: kMyDataSym, // fax data frame
myData: ...},
appSymbol: kAppSymbol,
currentFormat: kOtherPrintFormatSym
};
Send('fax, myItem);
You must construct an item frame containing the data and other slots that you
want to set in the item. You then pass this item frame as an argument to the
Send
function.
Before calling the
Send
function, you may want to allow the user to choose a
format for the item being sent. To do this, you'll need a list of formats that can
handle the item. To get a list of appropriate formats, you can use the
GetRouteFormats
function. Using this list, you could display a picker from
which the user can choose a format.
You may also want to allow the user to choose a transport for the item being sent.
To do this, you'll need a list of transports that can handle specific formats. To get a
list of appropriate transports, you can use the
GetFormatTransports
function.
In the
Send
function, it's best to specify a transport group or let the user choose
the transport. If you specify a specific transport, it may not be installed and the
operation will fail.
In the
Send
function, the Routing interface obtains a default item frame from the
selected transport by sending the
NewItem
message to the transport. The slots you
specify in your item frame are copied into the default item frame obtained from the
transport. Note that the default frame supplied by the transport may contain other
slots used by the transport.
The slots you include in the item frame vary, depending on the transport. The In/
Out Box and transports ignore slots they don't care about. Applications can use this
feature to communicate information to multiple transports with the same item
frame. For a comprehensive list of slots and detailed descriptions, see "Item
Frame" (page 18-1) in Newton Programmer's Reference.