http://www.newton-inc.com/dev/techinfo/qa/qa.htm
data := [....]; for item := 0 to Length(data) - 1 do ep:Output(data[ item ], nil, nil);
A: When protoBasicEndpoint
performs a function synchronously, it creates a special kind of "sub-task" to perform the interprocess call to the comm tool task. The sub-task causes the main NewtonScript task to suspend execution until the sub-task receives the "operation completed" response from the comm tool task, at which time the sub-task returns control to the main NewtonScript task, and execution continues.ep.fData := [....];ep.fIndex := 0;ep.fOutSpec := { async: true, completionScript: func(ep, options, error) if ep.fIndex >= Length(ep.fData) - 1 then // indicate we're done else ep:Output(ep.fData[ ep.fIndex := ep.fIndex + 1 ], nil, ep.fOutSpec ) };ep:Output(ep.fData[ ep.fIndex ], nil, ep.fOutSpec );
completionScript
) and exit gracefully. Such code is left as an excercise for the reader.