4D v14

Pointers

Home

 
4D v14
Pointers

Pointers    


 

 

In addition to the manipulations explained in the video, you should also note that:

Using a pointer is pretty easy. The advantage of its use is to make programming even more generic and adaptable.

The concept of a pointer is a simple one that we use everyday in speaking.

In the sentence “my dog is at home”, we use two pointers or indirections.

In fact, “my dog” doesn’t define the name or breed of the dog. You would need to know who is speaking to define what dog we’re talking about. That also goes for the house.

If Paul says “put it in the drawer” - what drawer is he talking about?

The drawer Paul indicated with his finger. He pointed to a drawer that the other person will “de-point” (look towards which drawer Paul’s finger is pointing).

This simple notion works well in 4D and allows replacing drawers with tables, fields, or variables.

If I ask 4D to perform a query in this table, I first need to define which table to query by pointing to it as follows:

 MyPointer:=->[TABLE]

At first, you may have a little trouble with pointers but you will soon find that they are simple to set up and provide you with a considerable amount of power.
Pointers are often used as parameters for methods that you call. We recommend that you spend some time familiarizing yourself with their use because they are sure to come in handy whenever you find yourself thinking:

  • "I'm going to duplicate this button"
  • or "I need to copy this method and then adapt it".

When you have to manage lists of pointers, then you can look into pointer arrays.

Remember that you can also use the Get pointer command that lets you set the name of pointers based on a character string. For example:

 Get pointer("MyVariable"+String($i))

 
 

 
PROPERTIES 

Product: 4D
Theme: Pointers

 
ARTICLE USAGE

Self-training ( 4D v13)
Self-training ( 4D v14)