[Gambas-user] How to delete copy of class/object
Ron
ron at ...1740...
Thu Jan 19 14:23:53 CET 2012
Hi community,
Let say I have a class called CMyMsg like this:
' Gambas class file
PUBLIC Length AS Integer ' packet length
PUBLIC Prio AS Integer ' 0 = normal, 1 = system
PUBLIC Node AS Integer ' node id
PUBLIC Key AS String
PUBLIC Packet AS NEW Byte[] ' data to send
PUBLIC AwaitAck AS Boolean
PUBLIC SUB SetLength(iLength AS Integer)
Length = iLength
END
PUBLIC SUB SetPrio(iPrio AS Integer)
Prio = iPrio
END
PUBLIC SUB SetNode(iNode AS Integer)
Node = iNode
END
PUBLIC SUB SetKey(sKey AS String)
Key = sKey
END
PUBLIC SUB SetPacket(aPack AS Byte[])
Packet = aPack
END
PUBLIC SUB SetAwaitAck(bAck AS Boolean)
AwaitAck = bAck
END
And I instantiate several copies of it in my project with this:
PRIVATE oMyMsgs AS NEW Object[]
PUBLIC SUB CreatePacket()
DIM MyMsg AS NEW CMyMsg
MyMsg.SetKey(Rnd)
MyMsg.SetLength(iPacketLen + 2)
MyMsg.SetPrio(0)
MyMsg.SetAwaitAck(TRUE))
MyMsg.SetPacket(bBuffer)
oMyMsgs.Add(MyMsg)
END
Further down, I loop through these objects in oMyMsgs and do something
with them like this:
PUBLIC SUB ParsePackets()
DIM MyMsg AS CMyMsg
FOR EACH MyMsg IN oMyMsgs
ProcessIt(MyMsg)
' question is how to delete the MyMsg entry here and remove it from
oMyMsgs objects list?
' or is there another way to do this efficiently?
NEXT
Thanks in advance!
Regard,
Ron_2nd.
More information about the User
mailing list