User Manual

59
CATC MERLINS WAND 1.22 CHAPTER 5
User’s Manual Script Manager
Trace("Disconnect returned: ", status, "\n\n");
}
Sample-2.script
# Sample2.script
#
# Demonstrates using RFCOMM to wait for and receive data as
well as the use of pipes.
#
# A Transmit pipe called "SamplePipe" should be created in
the Data Transfer Manager
# before the script is run. This pipe should contain a small
amount of data that will be sent
# back to the host whenever data is received by the script.
Main()
{
# Do some pipe tests.
result = DeletePipe("TestPipe", "receive");
Trace("DeletePipe returned ", result, "\n");
result = OpenPipe("TestPipe", "receive");
Trace("OpenPipe returned ", result, "\n");
# WritePipe only supports receive pipes.
result = WritePipe("TestPipe", "This is some data.");
Trace("WritePipe returned ", result, "\n");
result = ClosePipe("TestPipe", "receive");
Trace("ClosePipe returned ", result, "\n");
result = OpenPipe("TestPipe", "receive");
Trace("OpenPipe (2) returned ", result, "\n");
result = ReadPipe("TestPipe", "receive", 100);
Trace("ReadPipe returned ", result, "\n");
#result = ClosePipe("TestPipe", "receive");
#Trace("ClosePipe (2) returned ", result, "\n");
channel = RFRegisterServerChannel();
Trace("Listening on server channel ", channel, "...\n");
result = OpenPipe("DataIn", "receive");
Trace("OpenPipe returned ", result, "\n");
# Wait for a connection
status = RFWaitForConnection();