how to use delete each?
Thanks.
Type Monster
Field Name$
Field X, Y
End Type
ThisMonster.Monster = New Monster
ThisMonster\Name$ = "Bartholemew"
ThisMonster.Monster = New Monster
ThisMonster\Name$ = "Humperdink"
For ThisMonster.Monster = Each Monster
Print ThisMonster\Name$
Next
Output:
Bartholemew
Humperdink
Delete Each Monster
For ThisMonster.Monster = Each Monster
Print ThisMonster\Name$
Next
Output:
(Nothing)
"Delete Each" simply deletes all copies of a type you have created with New.
In fact, Delete Each isn't actually a command, it is two commands. The main command is Delete. The word Each is a modifier telling Delete what to delete.
So you can:
Delete First Monster
or
Delete Last Monster
or
Delete Each Monster
or
Delete ThisMonster
Beaker:
I think my example is longer! :-)
Wow - never knew about "Delete Each." :)
me neither (or either as the American's say). I always did a for look with each, and called delete for every instance.
You can even do this:
Type thing
Field x,y
End Type
For f = 0 To 10
th.thing = New thing
th\x = f
Next
Delete After First thing
Delete Before Last thing
For th.thing = Each thing
Print th\x
Next
Stop
End
ie. After First and Before Last.
that's petty cool, not sure how much use it is, but it's cool