dynamic allocation of a list

dynamic allocation of a list

  
I am processing a complex object (header with many detail records) from a REST service POST action.  In the process, I loop through the list of detail records posted.  I would like to return a list of result codes as part of the POST.  I have a structure to capture the returned message contents, but I don't know how to allocate a response list that is as long as the input list.  The documentation states that you can't call list_append inside a for loop, so how do you capture the result of processing the input records?
The documentation says you cannot listappend to the list you are looping through. Which makes perfect sense, because you end up creating an infinite evergrowing loop then. It's perfectly fine to listappend to a different list.
Thanks for the clarification.  I was successful.