Cicode Programming Reference > Cicode Function Categories > Task Functions Introduction > MsgRPC


Calls a remote procedure on another CitectSCADA computer. You can call any of the built-in Cicode functions remotely, or your own functions. You pass the Name of the function as a string, not as the function tag, and pass all the arguments for that function in Arg.

You can call the function in synchronous or asynchronous Mode. In synchronous mode, MsgRPC() does not return until the remote function is called and the result is returned. In asynchronous mode, MsgRPC() returns before the function is called, and the result cannot be returned.


MsgRPC(hMsg, Name, Arg, Mode)


The message handle, returned from the MsgOpen() function. The message handle identifies the table where all data on the associated message is stored.


The name of the function to call remotely, as a string.

If this function returns an error, you should confirm that the name you have used is not a label instead of the actual function name. Some functions are aliased using a label, for example, the function _AlarmGetFieldRec is defined in the labels database as "AlarmGetFieldRec". In this case, only "_AlarmGetFieldRec" should be passed to MsgRPC.


The arguments to pass to the function, separated by commas (,). Enclose string arguments in quotes "" and use the string escape character (^) around strings enclosed within a string. If you do not enclose the string in quotes, then the string is only the first tag found.


The mode of the call:

0 - Blocking mode - synchronous.

1 - Non-blocking mode - asynchronous.

Return Value

The result of the remote function call (as a string). If the function is called in asynchronous mode the result of the remote function cannot be returned, so an empty string is returned.

Related Functions

MsgOpen, MsgClose, MsgRead, MsgWrite


! Call remote procedure, call MyRPC() on server. Wait for result
! Call remote procedure, pass two strings. Don't wait for call to complete.
! be careful of your string delimiters as shown.
MsgRPC(hMsg,"MyStrFn","^"First string^",^"Second string^"",1);
! Call remote procedure, pass Cicode string. Don't wait for call to complete.
STRING sMessage = "this is a message";
MsgRPC(hMsg,"MyStrFn","^"" + sMessage + "^"",1);
! These functions could be used to acknowledge an alarm by record from any CitectSCADA Client on the network.
! The AlmAck() function is initialized by the Control Client (Don't forget that servers are also Control Clients.)
! The Alarm tag is passed into the function as a string and a message is sent to the Alarms Server to initialize
! the AlmAckMsg() function.
AlmAck(String AlmTag)
INT hAlarm1;
hAlarm1 = MsgOpen("Alarm", 0, 0);
MsgClose("Alarm", hAlarm1);
! The AlmAckMsg() function is executed on the Alarms Server that the client is connected to. This could be
! either the primary or standby Alarms Server. The function performs the alarm acknowledge.
AlmAckMsg(String AlmTag)

See Also

Task Functions