Tech Tip: Extracting a Field comment from the property
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: December 28, 2018
In the structure editor, there is an area in the field properties of a table to insert comments:
The following utility method can extract the comments of a field programatically:
//--------------------------------------------------------------------------------- // Name: EXTRACT_FIELD_COMMENT // Description: Method will extract the Comment property of a Field // // Parameters: // $1 (POINTER) - Pointer to the field // // Output: // $0 (TEXT) - Text of the Comment // -------------------------------------------------------------------------------- C_POINTER($1;$ptrField) C_LONGINT($pos;$pos2;$pos3) C_TEXT($0;$vTStruc;$comment;$fieldNum;$search1;$search2;$search3) $ptrField:=$1 $fieldNum:=String(Field($ptrField)) $search1:="id=\""+$fieldNum+"\">" $search2:=" $search3:=" EXPORT STRUCTURE($vTStruc) $pos:=Position($search1;$vTStruc) // search for ID $pos2:=Position($search2;$vTStruc;$pos) $pos3:=Position($search3;$vTStruc;$pos2+Length($search2)) $comment:=Substring($vTStruc;$pos2+Length($search2);$pos3-$pos2-Length($search2)) $0:=$comment |
Here is an example to extract the field "firstName" comments:
C_TEXT($comment) $comment:=EXTRACT_FIELD_COMMENT (->[Table_1]firstName) // Comments for firstName field |