I've got about 40 hours in trying to figure this out
				if #tpForm.obj.pChildren
					pointer pChild=NULL
					pointer pos3 = ListGetFirst(#tpForm.obj.pChildren)
					WHILE pos3 
						pChild = ListGetData(pos3)
						'delete CN_CHILDWIN from parents controllist
						if (#<ebd_control>pChild.obj.obj_type=TYPE_CONTROL)
							if (#<ebd_control>pChild.control_type=CN_CHILDWIN) 
								gx=0
								while gxform[gx]<>""
									if (#<ebd_control>pChild.custom=gxform[gx])
										RemoveChildWin(tpForm,pChild)
									endif
									gx++
								endwhile
							endif
						endif
						pos3 = ListGetNext(pos3)
					ENDWHILE
				endif
#tpForm.obj.pChildren is a pointer to a linkedlist of controls for a form
I'm looping through the linkedlist looking for a pointer to a control on the form
I know I have the right one when the if conditions are met and the 'custom' field is a match to one of the values in gxform[gx]
When I have a match I call RemoveChildWin(tpForm,pChild)
global sub RemoveChildWin(pointer pForm,pointer pChild)
	pointer pos,pData
	if pForm and pChild
		pos = ListGetFirst(#<ebd_object>pForm.pChildren)
		while pos
			pData = ListGetData(pos)
			if(pData = pChild)
				ListRemove(pos,FALSE)
				delete pData
				return
			endif
			pos = ListGetNext(pos)
		endwhile
	endif
endsub
When I run through the code with the call to RemoveChildWin remarked out everything works fineand with some print statements I can see the contents as i expect(so the data is indeed there)
When the RemoveChildWin is called it removes the item but then crashes 
pChild is 0xFEEEFEEE
when the desired control is deleted and it was the only control in that list it still makes it through the pos = ListGetNext(pos)
and satisfies the while.
I was getting the same sort of crash when I was trying it with a FOR EACH NEXT loop.
I hope it is something simple and stupid that I'm doing.
I don't have a clue.
LarryMc
			
			
			
				Larry,
Does it work to have a "return" in the middle of an if..endif statement.  I've never been able to make that work.
Later,
Clint
			
			
			
				You cqan put a return any where you want it.
Not a problem
Larry
			
			
			
				Larry, in the first code block you call RemoveChildWin. It will find and delete the same list node as you have stored in pos3, so pos3 can not be used when RemoveChildWin returns.
You should restart the enumeration, or reload pos3 with the last non-deleted or previous node:
1.
RemoveChildWin(tpForm,pChild)
pos3 = ListGetFirst(#tpForm.obj.pChildren)
if (!pos3) then exit from loop
2.
pos3 =*<LINKEDLIST>pos3.pPrev
RemoveChildWin(tpForm,pChild)
if (!pos3) then exit from loop
Or, add additional pointer variable "pChildToDelete". It should be NULL by default. Instead calling RemoveChildWin, assign pChildToDelete to pChild and continue enumeration.
After you call ListGetNext, check if pChildToDelete in not NULL, and here make a call to RemoveChildWin, then set it back to NULL.
pointer pos3 = ListGetFirst()
WHILE pos3 
	pointer pChildToDelete = NULL
	pChild = ListGetData(pos3)
	if (should delete)
		pChildToDelete = pChild
	endif
	pos3 = ListGetNext(pos3)
	if (pChildToDelete) then RemoveChildWin(tpForm,pChild)
ENDWHILE
			
			
			
				Sapero
Your "fix" worked.  I also had to adapt it to a second area where the same thing was happening.
I knew it would fix it.  It wasn't a matter of whether or not you could fix it; it was just a matter of when you would come on-line and solve my problem.
As always, thanks a million.
LarryMc