Consider the following:
You have a huge list of gadgets for a gui. Each one is held in the same type list.
So
Now, the user wants to create a gadget. Here is what we do to make it easy!
So the user creates his gadget using the following:
Now we can refference their object easily by its handle!
So if the user wants to change the object x and y with the following function
Now the user can change the properties, and we easily refferenced which object they wanted to change by lettting them do this
So we can easily get which object is being refferenced by merely refferencing its handle.
Also consider the following. What if you filled the screen with cubes and wanted te user to select a cube. How would you know which cube he selected? You can create a list of cubes and cycle through each one seeing it it's entity was the picked one. But that takes waaaaayyyy too long!
You could easily refference each entity with the handle of the type like so
So you see, you can easily manage large numbers of objects in the lists without having to cycle through the list manually to look for something. All you need to do is refference what it is by handle() and then retrieve the list object using object()!
It is the best thing that ever happened to blitz in my opinion!
You have a huge list of gadgets for a gui. Each one is held in the same type list.
So
Type Gadget field X,Y End Type
Now, the user wants to create a gadget. Here is what we do to make it easy!
Function CreateGadget(X,Y) local G.Gadget G=new Gadget G\X=X G\Y=Y return handle(G) End Function
So the user creates his gadget using the following:
MyGadget = creategadget(5,5)
Now we can refference their object easily by its handle!
So if the user wants to change the object x and y with the following function
Function Position(GAD,X,Y) local G.Gadget G=object.Gadget(Gad) if G<>null then G\X=X G\Y=Y Endif End Function
Now the user can change the properties, and we easily refferenced which object they wanted to change by lettting them do this
;Changing my gadgets position Position(MyGadget,15,15)
So we can easily get which object is being refferenced by merely refferencing its handle.
Also consider the following. What if you filled the screen with cubes and wanted te user to select a cube. How would you know which cube he selected? You can create a list of cubes and cycle through each one seeing it it's entity was the picked one. But that takes waaaaayyyy too long!
You could easily refference each entity with the handle of the type like so
Type cubelist field Cube end type Graphics3d 800,600,16,2 setbuffer backbuffer() cam = createcamera() for a = 1 to 500 makeCube(rnd(-100,100),rnd(-100,100),rnd(1,1000)) next While not keydown(1) if mousedown(1) then ent=camerapick(cam,MouseX(),MouseY()) GetSelected(Ent) endif renderworld flip wend end Function MakeCube(X,Y,Z) local C.CubeList C.Cubelist = new cubelist C\Cube = createcube() Positionentity(C\cube,x,y,z) entitypickmode(C\Cube,2) ;Name the entity with our handle nameentity(C\Cube,handle(c)) end function Function GetSelected(Ent) local C.CubeList C=object.cubelist(entityname(ent)) if C<> null then entitycolor(C\Cube,255,0,0) end function
So you see, you can easily manage large numbers of objects in the lists without having to cycle through the list manually to look for something. All you need to do is refference what it is by handle() and then retrieve the list object using object()!
It is the best thing that ever happened to blitz in my opinion!