Iterate records by index in TVirtualTable

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
DmitryV
Posts: 12
Joined: Mon 05 May 2014 04:33

Iterate records by index in TVirtualTable

Post by DmitryV » Fri 27 Jul 2018 03:04

Hello, there is feature request :-)

Subj; for iterate records like this
for i := 0 to RecCount - 1 do
, without moving the internal cursor, approximately as in TMemTableEh (EhLib).

I mean it would be very useful, especially with the possibility of moving some records to another index position.


Can it be implemented in future versions? Somewhen

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Iterate records by index in TVirtualTable

Post by MaximG » Mon 30 Jul 2018 09:37

Please describe the functionality you suggest in more detail. Perhaps you can compose a small piece of code that explains the essence of your suggestion.

DmitryV
Posts: 12
Joined: Mon 05 May 2014 04:33

Re: Iterate records by index in TVirtualTable

Post by DmitryV » Mon 30 Jul 2018 10:47

Sometimes, is necessary to go through the dataset's records in a loop with a counter, like a the array of records (including, when the record's fields is pre-unknown).
Code, which i mean may by is similar... on an example of artless bubble sorting:

Code: Select all

var     
  VT       : TVirtualTable;
  i, j     : Integer;
  // Hipotetical class implementing of single VT's record, or just pointing to it
  VTRecord : TVirtualTableRecord;   
begin
  ...
  for i := 0 to VT.RecordCount - 1 do  
    for j := 0 to VT.RecordCount - 2 do	
      if VT.Records[j].FieldByName('Sum').AsInteger <
        VT.Records[j + 1].FieldByName('Sum').AsInteger then
      begin
        // Also, there could be a MoveTo method with a distance argument 
        // for moving the record taken on the index both up and down
        VTRecord  := VT.Records[j];
        VT.Records[j] := VT.Records[j + 1];
        VT.Records[j + 1] := VTRecord;
      end;	  
end; 

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Iterate records by index in TVirtualTable

Post by MaximG » Fri 31 Aug 2018 05:26

Thank you for the suggestion. You can leave your suggestions at our UserVoice page ( https://devart.uservoice.com/forums/104 ... components ), and if there are many votes for your suggestion, we will implement it.

Post Reply