PDTransferImpl.mesa
Michael Plass, November 17, 1983 4:25 pm
DIRECTORY IO, FileIO, MessageWindow, PDInterpBasic, PDInterpControl, PDTransfer, PDTransferRpcControl, PDInterpControlRpcControl, MesaRPC;
PDTransferImpl: PROGRAM
IMPORTS IO, FileIO, MessageWindow, PDInterpControl, PDTransferRpcControl, MesaRPC, PDInterpControlRpcControl
EXPORTS PDTransfer
~ BEGIN
stream: IO.STREAM ← FileIO.Open["banded.pd"];
ReOpen: PROC ~ {IO.Close[stream]; stream ← FileIO.Open["banded.pd"]};
aborted: BOOLEANFALSE;
GetBlock: PUBLIC PROC [sourceIndex: INT, words: INT] RETURNS [dataBlock: PDTransfer.DataBlock] ~ {
bytesRead: INT ← stream.UnsafeGetBlock[[@(dataBlock.buffer[0]), 0, 2*MIN[words, PDTransfer.maxWords]]];
dataBlock.words ← bytesRead/2;
};
mess: CARDINAL ← 0;
ReportStatus: PUBLIC PROC [status: PDInterpBasic.Status, queueSize: NAT, queuePosition: NAT, page, pass, sourceIndex: INT] RETURNS [abort: BOOLEAN] ~ {
s: IO.STREAMIO.CreateOutputStreamToRope[];
s.Put[IO.refAny[NEW[PDInterpBasic.Status ← status]]];
s.PutRope[", "];
MessageWindow.Append[IO.GetOutputStreamRope[s], mess MOD 4 = 0];
mess ← mess + 1;
s.Close[];
abort ← aborted;
};
DoIt: PROC ~ {
pageSpec: PDInterpControl.PageSpec;
requestorName: LONG STRING = "Plass.pa"L;
interfaceName: MesaRPC.InterfaceName ← [instance: requestorName];
pageSpec[0] ← [0, LAST[NAT]];
PDTransferRpcControl.ExportInterface[interfaceName: interfaceName, user: "Plass.pa", password: MesaRPC.MakeKey
["iotw3799"]
];
PDInterpControlRpcControl.ImportInterface[[instance: NIL]
! MesaRPC.ImportFailed => {
s: IO.STREAMIO.CreateOutputStreamToRope[];
s.PutRope["Unable to access PDInterpControl: "];
s.Put[IO.refAny[NEW[MesaRPC.ImportFailure ← why]]];
MessageWindow.Append[IO.GetOutputStreamRope[s], TRUE];
MessageWindow.Blink[];
GOTO Quit;
}
];
PDInterpControl.RequestService["Plass.pa", pageSpec];
EXITS Quit => NULL;
};
END.