[Next] [Previous] [Up] [Top] [Contents] [Index]

11.1 General Utilities

11.1.2 Message Handling

void SaveMessageAndMakeCode(GetMsgCodeStruct *params, long PSYXid);

This utility should be called in response to a pGetMsgCode message (see "1.4 Standard Messages") when the PSYX wishes to accept any string message and read the string when it is called to execute the message.

params should be the message data pointer passed in for the pGetMsgCode message, and PSYXid should be the name of the PSYX that received the message. SaveMessageAndMakeCode() will generate a unqiue message id and fill in the GetMsgCodeStruct appropriately. Later, when the PSYX receives a message it does not recognize, it should call LoadMessageString().

int LoadMessageString(long msg, long id, char *buffer);

This utility should be called by a PSYX that has used SaveMessageAndMakeCode() when it receieves an unrecognized message. If LoadMessageString() returns TRUE, then the message code was one generated by SaveMessageAndMakeCode() and buffer is filled in with the original string message. (Buffer should be at least 256 bytes long).

If LoadMessageString() returns FALSE, then the PSYX should return FALSE, indicating to the PSYX manager that the message was not understood.

struct CodeFuncPair *CreateFunctionTable(long firstID, ...);

This utility can be used to build a message table. The parameters should be an alternating list of message IDs and function pointers; the function pointer following an ID is the message handler for that message. The list must be terminated with a 0, following the last function pointer.

CreateFunctionTable() returns a pointer that can be the reply to a pGetFuncTable message. This table must be freed before the PSYX is purged using Free() (capital "F") in response to a pDeinitialize message. The table should never be freed before the pDeinitialize message.

PSYX Programmer's Manual - 24 AUG 95
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with CERN WebMaker