Scroll to navigation

GOLF(2gg) Development GOLF(2gg)

NAME

read-fifo - (FIFO)

PURPOSE

Reads key/value pair from a FIFO list.

SYNTAX

read-fifo <list> \

key <key> \
value <value> \
[ status <status> ]

DESCRIPTION

read-fifo retrieves an element from the FIFO <list> into <key> string (in "key" clause) and <value> string (in "value" clause).

Once an element has been retrieved, the next use of read-fifo will obtain the following one, in the same order they were put in. read-fifo starts with the first element put in, and moves forward from there, unless rewind-fifo is called, which positions back to the first one.

If the element is successfully retrieved, <status> number (in "status" clause) is GG_OKAY, otherwise it is GG_ERR_EXIST, which means there are no more elements to retrieve.

EXAMPLES

In this example, a FIFO list is created, and two key/value pairs added. They are then retrieved in a loop and printed out (twice with rewind), and then the list is purged:

// Create a list
new-fifo mylist
// Add data to the list
write-fifo mylist key "key1" value "value1"
write-fifo mylist key "some2" value "other2"
start-loop

// Get data from the list
read-fifo mylist key k value v status st
// Check if no more data
if-true st not-equal GG_OKAY
break-loop
end-if
@Obtained key <<print-out k>> with value <<print-out v>> end-loop // Go through the list again, use rewind-fifo for that rewind-fifo mylist start-loop
read-fifo mylist key k value v status st
if-true st not-equal GG_OKAY
break-loop
end-if
@Again obtained key <<print-out k>> with value <<print-out v>> end-loop purge-fifo mylist

SEE ALSO


FIFO

delete-fifo new-fifo purge-fifo read-fifo rewind-fifo write-fifo See all documentation

$VERSION $DATE