Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022

read-fifo



PURPOSE:


Reads key/value pair from a FIFO list.

SYNTAX:


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


DESCRIPTION:


read-fifo retrieves a key/value pair from the FIFO <list>, storing them into <key> (in "key" clause) and <value> (in "value" clause), both of which can be created as strings with optional "define".

Once a key/value pair has been retrieved, the next use of read-fifo will obtain the following pair, in the same order they were put in. If the obtained <key> is NULL, the end of the list was reached. read-fifo starts with the first key/value pair put in, and moves forward from there, unless rewind-fifo is called, which positions back to the first pair.

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"

while (1) {
    // Get data from the list
    read-fifo mylist key define k value define v

    // Check if no more data
    if (k == NULL) {
        break;
    }

    @Obtained key <<p-out k>> with value <<p-out v>>
}

// Go through the list again, use rewind-fifo for that
rewind-fifo mylist

while (1) {
    read-fifo mylist key define k value define v
    if (k == NULL) {
        break;
    }
    @Again obtained key <<p-out k>> with value <<p-out v>>
}

purge-fifo mylist


SEE ALSO:


FIFO ( new-fifo   purge-fifo   read-fifo   rewind-fifo   write-fifo  )  SEE ALL (documentation)



Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Icons copyright PaweĊ‚ Kuna licensed under MIT. This web page is licensed under CC-BY-SA-4.0.