; Handle Example ; -------------- ; A tiny monster roster - the sort of list a game keeps for its enemies Type Monster Field name$ Field hp End Type For i=1 To 3 m.Monster=New Monster m\name="Goblin "+i m\hp=i*10 Next ; Handle turns a Type object into a plain integer. That number can go ; into a save file, a bank or a network message - places a Type object ; itself cannot travel. Print "Roster:" For m.Monster=Each Monster Print " "+m\name+" hp "+m\hp+" handle "+Handle(m) Next Print "" ; Asking for the same object twice always gives the same number boss.Monster=Last Monster Print "Same object asked twice : "+Handle(boss)+" then "+Handle(boss) ; A Null object always handles to 0, so 0 is a safe "nobody" value nobody.Monster=Null Print "Handle of a Null object : "+Handle(nobody) Print "" ; Object turns the number back into the object again saved=Handle(boss) back.Monster=Object.Monster(saved) Print "Object.Monster("+saved+") is "+back\name ; After the object is deleted the same number resolves to Null, which ; is a cheap way to spot a reference that has gone stale Delete boss gone.Monster=Object.Monster(saved) If gone=Null Then Print "After Delete, handle "+saved+" gives Null" Print "" Print "Press any key to close the example" WaitKey End