FieldNum

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods >

FieldNum

Declaration

function FieldNum( sFieldName: String ): Word;

Description

Gets number of named field in field array (relative to 1). This function is useful to test the validity of a field name.

Parameters

sFieldName: The name of the field.

Return Value

The relative position of the field in the field array (relative to 1). If the field does not exist, zero is returned.

Delphi Example

// Verify field name entered by user 

procedure Form1.Button1Click(Sender: TObject);

var

 sFieldName: String; 

 iFieldPos: Integer; 

begin

 // Get input from user 

 sFieldName := Edit1.Text; 

 if sFieldName = '' then  

         Exit; 

 

 // Determine field position; Zero if not found

 iFieldPos := ApTbl.FieldNum( sFieldName );

 

 if iFieldPos = 0 then 

         ShowMessage( 'Invalid field name' ) 

 else 

         ShowMessage( sFieldName + ' is #' + IntToStr( iFieldPos )); 

end;

See Also

ApolloFieldCount, FieldDecimals, FieldName, FieldOffset, FieldType, FieldWidth