GOLF(2gg)

πŸ“¦ version 601.4.41, in ubuntu questing

πŸ’– GOLF(2gg) β€” the read-fifo page, bestie edition πŸ’–

okay so you opened the GOLF(2gg) manual, section 2gg, and the star of this page is read-fifo. Development vibes only. let's get into it πŸ¦‹


✨ NAME ✨

read-fifo β€” (FIFO)


🎯 PURPOSE 🎯

Reads a key/value pair from a FIFO list. that's the whole job. she's focused, she's employed, she slays πŸ’…


πŸ“œ SYNTAX πŸ“œ

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

🌸 DESCRIPTION 🌸

so read-fifo retrieves an element from the FIFO <list> and drops it into the <key> string (that's the "key" clause) and the <value> string (that's the "value" clause). two little presents, one call 🎁

Once an element has been retrieved, the next time you use read-fifo you get the following one β€” same order they were put in, no queue-jumping, no cap. read-fifo starts with the first element that was put in and just keeps moving forward from there… unless rewind-fifo gets called, which positions you back to the first one. time travel, but legal ✨

If the element is successfully retrieved, the <status> number (in the "status" clause) is GG_OKAY. Otherwise it's GG_ERR_EXIST, which literally means there are no more elements to retrieve. that's it, the list said "no thoughts, empty" 😭


πŸ”₯ EXAMPLES πŸ”₯

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

// 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 🫢


and that's the page, bestie!! this was GOLF(2gg), dated $DATE, version $VERSION β€” mwah, go read a FIFO or whatever πŸ’œπŸ§š

πŸ“¦ where this page comes from