Function FieldInfo() Foundation

Sets or returns the settings for a field.

Syntax
FieldInfo( <nFieldPos>, <nDefine>, ;
                     [<xNewSetting>] ) --> xOldValue
Parameters
<nFieldPos>
<nFieldPos> is a positive integer specifying the ordinal position of the field whose settings are to be accessed within the work area.
<nDefine>
For the parameter <nDefine>, a #define constant from the #include file DMLB.CH is used. Constants for <nDefine> begin with the prefix FLD_.
<xNewSetting>
If included, the setting specified with <nDefine> is replaced by the value <xNewSetting>. A replacement is only possible for settings that may be changed.
Return

The return value of FieldInfo() is the value for the field setting specified by <nDefine>. If this is a changeable setting and <xNewSetting> is specified, the function returns the old value.

Description

The function FieldInfo() allows information about individual fields (field variables) in a work area to be accessed. To do this, a file must be open in the work area. If there is not an open file, a runtime error is generated when FieldInfo() is called. A detailed description of the information that can be retrieved using FieldInfo() is found in the chapter The Xbase++ Database Engine in the Xbase++ documentation.

Information about a work area can be retrieved using the function DbInfo().

Examples
Determine the structure of a single database field.

// The example shows the UDF FieldStruct() which returns 
// an array containing the structure of a single field. 
// The array structure is the same as a subarray of the 
// DbStruct() array. 

#include "Dmlb.ch" 

************** 
PROCEDURE Main 

   USE Customer 

   ? FieldName( 1 )      // result: CUSTOMERNO 
   ? FieldStruct( 1 )    // result: {CUSTOMERNO, C,      6,      0} 

   USE 
RETURN 

********************************* 
FUNCTION FieldStruct( nFieldPos ) 
RETURN { FieldName( nFieldPos )           , ;  // field name 
         FieldInfo( nFieldPos, FLD_TYPE ) , ;  // data type 
         FieldInfo( nFieldPos, FLD_LEN  ) , ;  // field length 
         FieldInfo( nFieldPos, FLD_DEC  )   }  // decimal places 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.