Tech Tip: Object properties cannot be referenced by a pointer
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: August 23, 2018
Object Notation is a new feature to 4D and an elegant way to code, especially how it can compartmentalize data within the object. One of the drawbacks to the feature is that a pointer cannot be made dirrectly to an object's property.
For Example the following code will generate an error:
C_OBJECT($varObject) C_POINTER($varPointer) $varObject:=New object("property";"Hello") $varPointer:=->$varObject.property |
However a pointer can be made to the object itself and the property can be accessed as normally such as in the sample code where bracket and dot variations of object notation is used:
C_OBJECT($varObject) C_POINTER($varPointer) $varObject:=New object("property";New object("subProp";"Hello")) $varPointer:=->$varObject $resultProperty:=$varPointer->["property"] $resultSubProp:=$varPointer->property.subProp TRACE |