TableFindNearest
Previous  Top  Next

Prototype

TableFindNearest
(intTableHandle,strFieldValue)

Description

It makes a search on the index currently selected inside the table and it places itself on the record having the field value quite similar to the one to be searched for, even if it has to be greater than itself.

Parameters

IntTableHandle
: integer value corresponding to the table handle.

StrFieldValue:
string corresponding to the field value.

Returned value

None.

Notes

None.

Example

//It opens a table
UnaTabella:=TableOpen('c:\invoices\index','invoices.db'); 

//It orders the table according to a field
TableSetIndex(UnaTabella,'Fiscal Code'); 

//It stores the index 1 field data
FieldValue:='Smith';

//It looks for data within the table and places itself on the record
TableFindNearest(UnaTabella,FieldValue);

//It stores the table field value into a variable 
FoundValue:=TableGetFieldByName(UnaTabella,'Fiscal Code');

// If the table value is different than the field one then…
If FoundValue<>FieldValue Then
Begin

//It sets the table insert mode   
TableInsert(UnaTabella);  
 
//It stores the field value in a new record  
TableSetFieldByName(UnaTabella,'Fiscal Code',FieldValue);  
 
//It confirms the table change   
TablePost(UnaTabella);  
End;

// It closes the table
TableClose(UnaTabella);