You might've run into the same thing I found, which is that removing the
last item in a FormList (that contains more than 1 entry) with either ListRemoveForm or ListRemoveNthForm seems to bug the list. I don't think I did any testing with ListReplaceNthForm to see if that avoid the problem, but I found another solution that might work better for you (has been working fine for me).
In a nutshell, that method is:
- Initialize the empty formlist with a dummy object
- Only add to the head of the list (any method is fine)
The dummy will always be the last item in the list, and you can safely remove any other with either of the remove functions. Actually, it should be safe to add at any index less than the list count - 1, but unless you need to, you should add at the head (index 0) since that's more efficient.
One other thing - I don't know if your formlists contain anything other than base forms, but if they do, I've found that ListGetFormIndex
will not return the index of a non-base form (it will always return -1). If you need the index in this case, you can use:
set iIndex to ListRemoveForm SomeFormList rSomeRef
...and if necessary add rSomeRef back afterward. If you're using the dummy-at-the-end method described above, you could safely add it back with:
ListAddForm SomeFormList rSomeRef iIndex ORrSomeRef.ListAddRef SomeFormList iIndex
...which will preserve the list's order.
I've already reported the apparent bugs to ianpatt, so they're on his list for things to look at.