CreatePort(name$)
OnUserMessage
event handler). If you do not install
this event handler, you will not get any notifications on incoming messages.
Please remember that message port names are always given in case sensitive notation. Thus, "MYPORT" and "myport" denote two different message ports. For style reasons it is suggested that you use only upper case characters for your port name. Furthermore, each message port must be unique in the system. If you specify a port name which is already in use, this function will fail. Thus, make sure that you use a unique name.
Please note that every Hollywood script can only have one message port. If you have already created a message port and call this function again, the old message port will be deleted.
See InstallEventHandler for more information on how the user callback function will be called.
Function p_EventFunc(msg) Switch msg.action Case "OnUserMessage" Switch msg.command Case "EXIT" DebugPrint("Exit received! Quitting now.") End Default Local t = SplitStr(msg.args, "\0") DebugPrint(msg.command, "called with", msg.argc, "argument(s)") For Local k = 1 To msg.argc DebugPrint("Argument", k .. ":", t[k - 1]) Next EndSwitch EndSwitch EndFunction CreatePort("MY_COOL_PORT_123") InstallEventHandler({OnUserMessage = p_EventFunc}) Repeat WaitEvent ForeverSave the code above as a Hollywood script and run it with Hollywood. Then save the following code as a new Hollywood script and run it:
SendMessage("MY_COOL_PORT_123", "INIT", "Value1", "Value2", "Value3") SendMessage("MY_COOL_PORT_123", "DO_SOMETHING", "Argument1") SendMessage("MY_COOL_PORT_123", "EXIT")The code above will then communicate with the first script. You can see that the messages are arriving from the debug output of script number one.