KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Dereferencing pointer to an array vs. array of pointer
PRODUCT: 4D | VERSION: | PLATFORM: Mac & Win
Published On: April 11, 2003

Versions: 6.7 and 6.8 and 2003

When you have a pointer referencing an array, you can dereference the array or its array elements by placing the dereferencing symbol (->) at the end of the pointer variable.

Suppose we reference a pointer to an array of Integer.

ARRAY INTEGER(arrInteger;2)
arrInteger{1}:=100
arrInteger{2}:=200

C_POINTER(vPointer)
vPointer:=->arrInteger

Here is the equivalency of dereferencing the pointer vPointer.

vPointer-> equals to arrInteger
vPointer->{1} equals to arrInteger{1}
vPointer->{2} equals to arrInteger(2}

In 4D, you can create an array of pointer elements. Each pointer element can reference to various different things.

For example

C_TEXT(Variable1)
Variable1:=”Hello”
ARRAY POINTER(arrPointer;2)
arrPointer{1}:=->Variable1
arrPointer{2}:=->arrInteger ` Pointer to arrInteger

Here is the equivalency of dereferencing the pointer arrPointer.

arrPointer{1}-> equals to Variable1
arrPointer{2}-> equals to arrInteger
arrPointer{2}->{1} equals to arrInteger{1}
arrPointer{2}->{2} equals to arrInteger{2}