FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MEMORY

Have a better understanding of handles & pointers


1) How do i create a pointer to an handle created with NEWHANDLE ?
Is it just: HandlePtr& = @MyHandle ?

It's time to be careful with terminology here. People often use the term "handle" when they really mean, "a relocatable block of memory which is referenced by a handle." The _handle_ is a 4-byte long integer (always). The _block_ it refers to can have any size.
Keeping that distinction in mind, the answer to (1) is yes, "HandlePtr& = @MyHandle&" gives you a pointer to the handle. But remember that this is _not_ a pointer to the the data block. To get a pointer to the block, use this:
  dataPtr& = PEEK LONG(MyHandle&)
or, equivalently:
  dataPtr& = [MyHandle&]
Once you've done this, beware of the fact that such a block can move to a different location in memory "without warning," and if it does, the value you stored into dataPtr& no longer points to the block.

2) How can i find out the size of the handle using just the pointer ? (with GETHANDLESIZE)

If "the pointer" is actually a pointer to the 4-byte handle, then you can get it like this:
  size& = GETHANDLESIZE([handlePtr&])
But if "the pointer" is a pointer to the data block--well, in that case I know of no way to get the handle's size.
BTW, "the size of the handle" is another example of that careless terminology (used by everybody including Apple). They should technically say, "the size of the block which is referenced by the handle."

3) Also, by just using the pointer, how can i, for example, read the 12th byte in the handle ?

Again, if it's a pointer to the _block_, do this:
  byte = PEEK(dataPtr& + 11)
(or safer, because it doesn't give the block a chance to move):
  byte = PEEK([MyHandle&] + 11)
4) How do i put, for example, 200 in the 12th byte of a handle ? (not using a pointer)

  POKE [MyHandle&] + 11, 200
Rick