KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Finding table name/pointer given a field pointer
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: April 20, 2015

Below is a quick utility method to obtaining table name/table pointer from a given field pointer:

// Method: GetTableFromField
// $1 - Pointer to Field
// $2 - Pointer to return table name
// $3 - Pointer to return table pointer
// ----------------------------------------------------

C_POINTER($1;$2;$3;$ptr_p;$tablename_pt;$tableptr_p)
C_TEXT($varname_t)
C_LONGINT($tablenum_l;$fieldnum_l)

If (Count parameters=3)

  $ptr_p:=$1
  $tablename_pt:=$2
  $tableptr_p:=$3

  RESOLVE POINTER($ptr_p;$varname_t;$tablenum_l;$fieldnum_l)
  If ($tablenum_l>0)
    $tablename_pt->:=Table name($tablenum_l)
    $tableptr_p->:=Table($tablenum_l)
  End if

End if


Example:
GetTableFromField (->[Table_1]Field_1;->$tablename;->$tableptr)
//$tablename returns "Table_1"
//$table_ptr returns ->[Table_1]