Provided by: golf_601.4.41-1_amd64 bug

NAME

       read-lifo -  (LIFO)

PURPOSE

       Reads key/value pair from a LIFO list.

SYNTAX

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

DESCRIPTION

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

       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. read-lifo starts with the last element put in, and moves backwards from
       there, unless rewind-lifo is called, which positions back to the last  one.  Note  that  write-lifo  will
       cause the next read-lifo to start with the element just written, i.e. it implicitly calls rewind-lifo.

       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 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:

           %% /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 ALSO

        LIFO

       delete-lifo get-lifo new-lifo purge-lifo read-lifo rewind-lifo write-lifo See all documentation

$DATE                                               $VERSION                                           GOLF(2gg)