Object does not exist?

BlitzPlus Forums/BlitzPlus Programming/Object does not exist?

Pineapple(Posted 2008) [#1]
This code continues to give one of two errors, which are seemingly random, because the only thing I have to modify to get it to change is to add an extra Print line for aid in debugging. With debug enabled, it will either pop up a 'blitzcc.exe has encountered a problem and needs to close. We are sorry for the inconvenience.' or the Blitz debugger highlights a random line saying 'Object does not exist'

The two functions in which the error is occuring:

Function ClearTreeView()
	If debug Print "Removing current treeview nodes..."
	For del=0 To elementNUM
		If parent(del)>-2 FreeTreeViewNode treenode(del)
		treenode(del)=False
	Next
	If debug Print "Removing groups..."
	For g.group=Each group
		g\img=False
		If GroupExists(g\parent)
			FreeTreeViewNode g\hand
			g\hand=False
		Else
			If debug Print "Did not delete group "+g\name+" because its parent has already been deleted."+g\parent
		EndIf
		Delete g
	Next
End Function

Function GroupExists(gname$)
	If gname="NONE" Or gname="ROOT" Then Return 1
	For g.group=Each group
		If g\name=gname Return 1
	Next
	Return 0
End Function




GroupExists simply checks to see if the spectified group exists, or if the parent of the given group is the root of the treeview these groups are in. Almost all the time, the object does not exist error absurdly highlights 'Return 0'

ClearTreeView frees all the tree view nodes, and when I attempt to free the nodes belonging to groups, it gives me an error.


I apologize for the lack of complete source, but the program it belongs to is not open source, and is almost 1500 lines of code anyway.


Pineapple(Posted 2008) [#2]
Nevermind, I found what was wrong. In the function GroupExists, I had to change g.group to c.group because ClearTreeView was also using g.group.

Thanks everyone for your help