ADDRESS null
NUMERIC DIGITS 10
OPTIONS "WINFUNC NOSOURCE"
SIGNAL ON FAILURE
SIGNAL ON SYNTAX
SIGNAL ON HALT
FUNCDEF("CreateMailslot", "void, str, 32u, 32, void", "kernel32",,"U1 -1")
FUNCDEF("GetMailslotInfo", "32, void, 32u *, 32 * stor, 32u * stor, 32u * dual", "kernel32",,"U1 0")
FUNCDEF("ReadFile", "32, void, void, 32u, 32u * stor, void", "kernel32",,"U1 0")
FUNCDEF("CloseHandle", "32, void", "kernel32")
SIGNAL ON user 1 NAME mailsloterror
handle = createmailslot("\\.\mailslot\testslot", , -1)
SIGNAL ON user 1 NAME mailsloterror2
SIGNAL ON SYNTAX NAME mailsloterror2
again:
err = 10000
CALL getmailslotinfo(handle, , msgsize, , err)
DO WHILE msgsize \= -1
buffer = CONVERTDATA(0, msgsize, , "A")
CALL readfile(handle, buffer, msgsize, numread)
IF msgsize \= numread THEN SAY "ERROR: The correct number of characters weren't received!"
ELSE DO
CALL CONVERTDATA(buffer, "buffer", , "=")
SAY buffer
END
CALL getmailslotinfo(handle, , msgsize)
END
SLEEP(60)
SIGNAL again
mailsloterror2:
SAY CONDITION('D') "failed:" UNIXERROR(RXFUNCERRMSG())
SIGNAL again
mailsloterror:
SAY CONDITION('D') "failed:" UNIXERROR(RXFUNCERRMSG())
SIGNAL HALT
syntax:
failure:
CONDITION('M')
halt:
IF SYMBOL(handle) == 'VAR' THEN closehandle(handle)
RETURN |
|