<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods > OrderPosGet |
Declaration
function OrderPosGet: Double;
Description
Retrieves the relative position of the current index key within the active order as a fractional percentage value.
Return Value
This is returned as a floating-point value between zero (0) and one (1) inclusive. For example, if the current key is 25% of the way through the index, the returned value is 0.25. If no index order is active (natural order) the result is always zero (0).
These values are derived by a rapid scan of the internal nodes of the index pages and may not be 100% precise. For example, moving to the top of the index may result in a value just over zero (ex. 0.005512). Similarly, moving to the end of the index may result in a value just over one (ex. 1.025). However, setting the value to 0 or 1 with OrderSetPos will always position you to the first and last keys (respectively).
Delphi Example
// Set scroll bar position
var
lCount: Integer;
begin
if (ApTbl.IndexName = '') then
begin
lCount := ApTbl.Count;
ScrollBar1.Position := FloatToStr(( ApTbl.RecNo / lCount ) * lCount );
end
else
ScrollBar1.Position := Trunc( ApTbl.OrderPosGet * 100 );
end;
C++Builder Example
// Set scroll bar position
long lCount;
if (ApTbl->IndexName == "")
{
lCount = ApTbl->Count();
ScrollBar1->Position = FloatToStr(( ApTbl->RecNo / lCount()) * lCount );
}
else
{
ScrollBar1->Position = Trunc( ApTbl->OrderPosGet() * 100 );
}
See Also