PTROF()


General Forms:

PTROF(ptrvar.field-variable [.fieldvariable ...])
PTROF(strexpr)

Where:
ptrvar = a numeric variable holding a PTR value from NEW or PTROF()
strexpr = a string

Field form

The first form of the PTROF() function has a similar syntax to the FLD() function but it can only be applied to dynamically allocated fields that were declared as type PTR and it will return a pointer reference for the field rather than its value. That pointer reference can be used in FLD() to get the value.

The function can also be used as a receiver to initialize or change a pointer. By convention a zero value implies an uninitialized pointer field.

String form

The second form of the PTROF() function returns the PTR, if applicable, for any string expression, and NULL otherwise.

Compatibility

Field form introduced with KCML 7.00. String form introduced with KCML 7.19.

Syntax examples:

pName = PTROF(rec$.name$)
pName = PTROF(pRec.name$)
PTROF(pRec.e$) = NEW PTR(X$_EmpRec)
PTROF(pRec.e$) = 0
pAddress = NEW PTR(X$_AddressRec) USING PTROF(sContactCard$)

See also:

NEW,
FLD(),
FLD($OPTIONS_RUN.OPTIONS_RUN_PromoteLocalDimStruct),
Tutorial on dynamic memory allocation