Tech Tip: Utility Method to get all field pointers to a given table
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: July 19, 2016
Below is an utility method that will return pointers to all the fields of a given table.
// Method: UTIL_GET_FIELD_POINTERS // Parameters: // $1 - Pointer to table // $2 - Array of pointers to contain field pointers C_POINTER($table;$1;$fieldPtrs;$2) C_LONGINT($tableNum;$lastFieldNum;$i) C_POINTER($fieldPtr) If (Count parameters>=2) $table:=$1 $fieldPtrs:=$2 ALL RECORDS($table->) $tableNum:=Table($table) $lastFieldNum:=Get last field number($table) $i:=1 For ($i;1;$lastFieldNum) If (Is field number valid($table;$i)) $fieldPtr:=Field($tableNum;$i) APPEND TO ARRAY($fieldPtrs->;$fieldPtr) End if End for End if |
Example:
To get pointers to the fields of the following table:
![](https://kb.4d.com:443/kbase/assets/images/77585-1.jpg)
Run the following code:
ARRAY POINTER($arrFieldPtrs;0) UTIL_GET_FIELD_POINTERS(->[Table_1];->$arrFieldPtrs) |
The results of $arrFieldPtrs:
![](https://kb.4d.com:443/kbase/assets/images/77585-2.jpg)