You can just create an array and loop through the inventory to put object pointers in it.
Code:
count := inven_count(dude_obj);
invenArr := temp_array_list(count);
for (i := 0; i < count; i++) begin
invenArr[i] := inven_ptr(dude_obj, i);
end
foreach (item in invenArr) begin
display_msg("Inv: " + obj_name(item));
end