Neil wrote:
For the explanation of how pointers work. They are explained in the help file/manual, but this doesn't help you understand why you should actually use them.
You are welcome, keep in mind here we just saw some of the reasons for using pointers.
Beyond the ones saw here the most common are:
To pass a variable to a procedure by reference
In PB normally you pass data by value (a copy of the original var), but if you want to modify the value of the passed variable you must use the "@" operator to actually pass its address. Then through that pointer you can access the real var (not a local copy) and change its contents.
To pass a structure to a procedure
In PB you can't pass a copy of a structure (there are some caveat, let's forget them for now) so you must pass the address of a structure.
Again you are using a pointer.
To use a callback
When you write/use a procedure which needs to communicate its progress to the main program while it's working, you can use a callback.
To call a callback your procedure needs the address of the procedure to be invoked. Again, that address it's a pointer, not to data but to a procedure.
To create dynamic structures in memory
A typical case is a linked list, or a tree. Every item of the list/tree is allocated dynamically using AllocateMemory() and each item is linked to another by storing the addresses of its neighbors as pointers.
... and much more
Just google "why use pointers" and you can read for a looooong time.