11.1 General Utilities
void SaveMessageAndMakeCode(GetMsgCodeStruct *params, long PSYXid);
This utility should be called in response to apGetMsgCodemessage (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.
paramsshould be the message data pointer passed in for thepGetMsgCodemessage, andPSYXidshould be the name of the PSYX that received the message.SaveMessageAndMakeCode()will generate a unqiue message id and fill in theGetMsgCodeStructappropriately. Later, when the PSYX receives a message it does not recognize, it should callLoadMessageString().
int LoadMessageString(long msg, long id, char *buffer);
This utility should be called by a PSYX that has usedSaveMessageAndMakeCode()when it receieves an unrecognized message. IfLoadMessageString()returnsTRUE, then the message code was one generated bySaveMessageAndMakeCode()and buffer is filled in with the original string message. (Buffer should be at least 256 bytes long).If
LoadMessageString()returnsFALSE, then the PSYX should returnFALSE, 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 apGetFuncTablemessage. This table must be freed before the PSYX is purged usingFree()(capital "F") in response to apDeinitializemessage. The table should never be freed before thepDeinitializemessage.
Generated with CERN WebMaker