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

TaskCall

Calls a Cicode function by specifying the function name and providing an arguments string.

The function will be executed in a new Cicode task with the same cluster context as the current task. The current task will be blocked until the new task completes and a value can be returned.

This function cannot be called from page foreground animation code. If this is attempted, a hardware alarm will be raised and IsError() will return 282 (Foreground Cicode cannot block).

TaskCall allows the function to be called and the arguments to be provided to be specified dynamically by the cicode logic. This may be useful in some cases where the function needed is not known until runtime.

CitectSCADA requests the required I/O device data and waits for the data to be returned before starting the function.

Syntax

TaskCall(sName, sArgs)

 

sName:

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

sArgs;

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.

Return Value

The result of the function call (as a string). If a void function is called, an empty string is returned. To see if an error occurred (such as an invalid function name or invalid arguments) call IsError()..

Related Functions

TaskNew, TaskNewEx

Example

STRING result;
result = TaskCall(“StrFill”, “^"abc^",10”);
// result will be set to "abcabcabca"

See Also

Task Functions