Handles and Numbers

Numbers

All created objects are identified by an arbitrary number (which is not the object's handle, as seen below). In this manual, these numbers are marked as #Number (for example, each gadget created have a #Gadget number).

The numbers you assign to them do not need to be constants, but they need to be unique for each object in your program (an image can get the same number as a gadget, because these are different types of objects). These numbers are used to later access these objects in your program.

For example, the event handling functions return these numbers:
  EventGadget()
  EventMenu()
  EventWindow()

Handles

All objects also get a unique number assigned to them by the system. These identifiers are called handles. Sometimes, a SpiderBasic function doesn't need the number as argument, but the handle. In this manual, such things are mentioned, as an ID.

Example

  ImageGadget(#Gadget, x, y, Width, Height, ImageID [, Flags])
  ; #Gadget needs to be the number you want to assign to the Gadget
  ; ImageID needs to a handle to the image.
To get the handle to an object, there are special functions like:
  FontID()
  GadgetID()
  ImageID()
  ThreadID()
  WindowID()
Also, most of the functions that create these objects also return this handle as a result, if they were successful. This is only the case if #PB_Any was not used to create the object. If #PB_Any is used, these commands return the object number that was assigned by PB for them, not the handle.

Example

  GadgetHandle = ImageGadget(...)