There may be times when connecting to a server via 4D Open that you may know the table but not the field that you need in order to update or perform some other data operation. The only information that you may know about the field is that it is the only Boolean field within the table. In this situation, you can use the 4D Open command OP Get field properties. This command will return a host of information about the fields within a given table.
In this example, we are looking for a Boolean field within our table. For simplicity's sake, let's assume that we are working with Table One.
ARRAY LONGINT(aTypes;0) ` field types
ARRAY LONGINT(aLength;0) ` field length (for alpha fields)
ARRAY LONGINT(aIndexes;0) ` indexed?
ARRAY LONGINT(aInvisible;0) ` invisible?
ARRAY STRING(15;aNames;0) ` field names
$File:=1 ` get information on file 1
$ErrCode:=OP Get field properties (vl_ConnectID;$File;$Invisible;aNames;aTypes;aLength;aIndexes;aInvisible)
For ($i;1;Size of Array(aTypes))
$Field:=$i 'fields are listed in order
Notice we are using a Longint array for aTypes. We could also make this into a string, text, real, or integer array. This command will return values depending on the type passed. For our Boolean example, our Longint array will return a 6 for Boolean, where as a string array would return a value of 'Boolean.'
Also, since the fields are returned in the order they appear in the structure, all we need to do is return the loop count which will be equivalent to the field number.