Read fifo

Purpose: Reads key/value pair from a FIFO list.

 read-fifo <list> \
     key <key> \
     value <value> \
     [ status <status> ]

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 successfuly 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
     end-if

     @Obtained key <<p-out k>> with value <<p-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
     end-if
     @Again obtained key <<p-out k>> with value <<p-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


Copyright (c) 2019-2024 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.