Parsing Nested Associative Lists

Several ProcScript functions return an associative list that can hold several levels of nested lists. The example ProcScript entry showidlist can be called to parse such lists.

ProcScript Entry showidlist

The showidlist entry parses an associative list returned by $procerrorcontext.

entry showidlist
params
   string list : IN
   string level : IN
endparams
variables
   string item
   string id
   string nextlist
   numeric index
endvariables

; end if we do not have an associative item
if ($idpart(list) = $valuepart(list))
   return
endif

index = 0   
repeat
   index = index + 1
   getitem item, list, index
   if ($status = 0)
      break
   endif
      
   id = $idpart(item)
   nextlist = $valuepart(item)
   putmess "Item %%level%%%.%%index%%%: ID = %%id%%%   VAL = %%nextlist%%%"

   call showidlist(nextlist, "%%level%%%.%%index%%%") 
until (1=0)
end

The displayed output depends on the input list.