KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Getting the correct field to use in 4D Open
PRODUCT: 4D Open | VERSION: 6.8 | PLATFORM: Mac & Win
Published On: July 2, 2002

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.

C_LONGINT($File;$ErrCode;$Field)

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))



 If (aTypes{$i}=6)



  $Field:=$i 'fields are listed in order



 end if

end for


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.