Deleting a Type

Blitz3D Forums/Blitz3D Beginners Area/Deleting a Type

Hardcoal(Posted 2011) [#1]
Thow it looks obvious I must Say.

When you delete a Type all its related types spaces are being deleted as well.

EXAMPLE:

---Code:
Type Object
Field General.Part
End Type

Type Part
Field Name
End Type

---Action:
Object1.Object = New Object
Object1\General= New Part

Delete Object1

---Result:
Also Object1\General Space is being Deleted


Warner(Posted 2011) [#2]
I'm afraid that is not correct. In the above case "Object" will be deleted, as expected, however, the Part will still be there.
You can try that by adding something like:
For p.Part = each Part
  print "part: " + p\name
Next

In order to delete both, first delete the fields, then the object itself:
Delete Object1\General
Delete Object1



Yasha(Posted 2011) [#3]
When you delete a Type all its related types spaces are being deleted as well.


Nope. this never happens. Warner is right, you must delete them separately.

Since we just had an excellent discussion on this same subject a few days ago, I strongly advise you go back and take a look at this thread: http://www.blitzbasic.com/Community/posts.php?topic=94874


Hardcoal(Posted 2011) [#4]
i made an experiment and i guess i came up with the wrong conclussion.
abit disspointing since it makes the job a little bit harder.


Warner(Posted 2011) [#5]
Maybe it helps if you make a function to delete a certain type of object.
Say in the example you gave you want to delete an Object. You could use the following function:
Function DeleteObject(o.Object)
   Delete o\General
   Delete Object
End Function

(Note that this code will not work directly, since Object is not a valid Type name)


Hardcoal(Posted 2011) [#6]
Sure its a good possebility.
thanks