GOLF(2gg)
π GOLF(2gg) β the read-lifo era π
okay bestie, this one lives in the GOLF manual, section 2gg, and it's lowkey one of the most satisfying little commands in the whole dev toolbox. no cap. π«Ά
β¨ NAME β¨
read-lifo β (LIFO) π₯
π― PURPOSE π―
Reads a key/value pair from a LIFO list. that's it. that's the whole job. and it eats every time. π
πΈ SYNTAX πΈ
read-lifo <list> \
key <key> \
value <value> \
[ status <status> ]
note the status clause is optional β the rest? mandatory, babes. β¨
π DESCRIPTION π
read-lifo retrieves an element from the LIFO <list> into the <key> string (that's the "key" clause) and the <value> string (that's the "value" clause). one element, two strings, iconic behaviour. π
Once an element has been retrieved, the next use of read-lifo will obtain the following one, in the reverse order they were put in. so it starts with the last element put in and moves backwards from there β unless rewind-lifo is called, which positions back to the last one. π¦
also important:write-lifowill cause the nextread-lifoto start with the element just written, i.e. it implicitly callsrewind-lifo. the way it just does that for you? main character energy fr fr. π
If the element is successfully retrieved, the <status> number (the "status" clause) is GG_OKAY. otherwise it's GG_ERR_EXIST, which means there are no more elements to retrieve. that's your signal to stop looping, bestie, don't fight it. π
π EXAMPLES π
In this example, a LIFO 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. it's giving full life cycle. π
%% /lifo public
new-lifo mylist
// Add data to the list
write-lifo mylist key "key1" value "value1"
write-lifo mylist key "some2" value "other2"
start-loop
// Get data from the list
read-lifo 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-lifo for that
rewind-lifo mylist
start-loop
read-lifo 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
// Delete all in LIFO
purge-lifo mylist
// Verify nothing is left
rewind-lifo mylist
read-lifo mylist key k value v status st
if-true st not-equal GG_OKAY
@LIFO is empty
end-if
%%
see how it loops, rewinds, loops again, then purges and confirms it's empty? that's the whole arc. character development. π§
π SEE ALSO π
LIFOdelete-lifoget-lifonew-lifopurge-liforead-liforewind-lifowrite-lifo- See all documentation π
and that's the page, babe. this manual was served up at version $VERSION back on $DATE β yeah, $DATE and $VERSION, that's the source stamp, keep it cute and keep it exact. GOLF(2gg) forever. π
β¨πΈπ¦π
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms