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

QueRead

Reads data from a queue, starting from the head of the queue. Data is returned in the same order as it was written onto the queue and is removed from the queue when read. If the Mode is 0 (non-blocking) and the queue is empty, the function returns with an error. If the Mode is 1 (blocking) the function does not return until another Cicode task writes data onto the queue.

This function is a blocking function. It will block the calling Cicode task until the operation is complete.

Syntax

QueRead(hQue, Type, Str, Mode)

hQue:

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

Type:

The integer variable to read from the queue (written to the queue as Type by the QueWrite() function).

Str:

The string variable to read from the queue (written to the queue as Str by the QueWrite() function).

Mode:

The mode of the read:

0 - Non-blocking.

1 - Wait for element.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

QueClose, QueLength, QueOpen, QueWrite, QuePeek

Example

Status=QueRead(hQue,Type,Str,0);
IF Status = 0 THEN
! Now use Type and Str.
...
END

See Also

Task Functions