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

ServerRPC

Calls a remote procedure on the Citect server specified by the ServerName argument. 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 and pass the arguments for that function in Arg.

You can call the function in synchronous or asynchronous Mode. In synchronous mode, ServerRPC() does not return until the function call has completed on the server and the result is returned. In asynchronous mode, ServerRPC() returns before the function is called, an empty string is returned as the result cannot be returned.

Syntax

ServerRPC(sServerName, sName, sArg, iMode [, sClusterName])

sServerName:

Citect server name where the Cicode function needs to be executed. You can optionally specify this name in <ClusterName>.<ServerName> syntax.

sName:

The name of the Cicode function to call remotely as string.

sArg:

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 forget to enclose the string in quotes, then the string is only the first tag found.

iMode:

The mode of the call:

0 - Blocking mode - synchronous

1 - Non-blocking mode - asynchronous

sClusterName:

The name of the cluster that the server resides in. This argument is optional, as in several situations it may not be required. In single cluster systems, it is not required, or if the current Cicode task already has the correct cluster context for the server you may omit this argument.

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. If the function cannot work due to an error, empty string is also returned and the error can be obtained by calling the IsError function.

Related Functions

TaskNew, TaskNewEx

See Also

Task Functions