Log In    |    Knowledge Base    |    4D Home
Tech Tip: Deriving a table name from a field pointer
Published On: July 31, 2002
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: 6.7.x and 6.8.x

When a pointer to a field is passed as a parameter, it is frequently desirable, or necessary, to have a pointer to the table to which the field belongs.

The following commonly used code reduces the need to pass a table pointer as a separate parameter.

Though the code in this routine is very short, it has been implemented in a separate routine named Shell_PointerToTableForField in order to be reused. Reuse, even of such small amounts of code, prevents errors (such as typos), and eliminates the need for retesting the code each time it is written.

Here is the 4D ORDER BY command using Shell_PointerToTableForField to return a pointer to a table:

ORDER BY(Shell_PointerToTableForField ($pFieldToOrderBy)->;$ pFieldToOrderBy ->;>)

Here is the code of Shell_PointerToTableForField:
If (False)
`$pTable:=Shell_PointerToTableForField (Field pointer)

`When passed a field pointer, returns a pointer to the fieldĖ‡s table.

`$1 Field pointer
`$0 Table pointer for field pointer passed in $1
End if