tableSort sorts all rows except row 0

General TRichView support forum. Please post your questions here
Post Reply
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

tableSort sorts all rows except row 0

Post by j&b »

If I sort a table I noticed that only all rows>0 are correct sorted.

In your UNIT tablesort.pas I stop running program in line

table := CreateSortedTable(rve, table, Column, ..., FirstRow, LastRow); (proc function DoSortCurrentTable(rve: ...))

FirstRow is always 1.

If I set FirstRow to 0 ALL rows are correct sorted.

FirstRow:= 0; //jb
table := CreateSortedTable(rve, table, Column, ..., FirstRow, LastRow);


Is there a reason why FirstRow is always 1 or is that an error ?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand the problem?

Do you mean that, even if you set FirstRow=0, the first row is not sorted?
I cannot reproduce it in the ActionTest demo. "Table | Sort..." command (that uses TableSort.pas) sorts the first row.
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Post by j&b »

>>Do you mean that, even if you set FirstRow=0, the first row is not sorted?

No, first row is sorted

>>Sort..." command (that uses TableSort.pas) sorts the first row.

That is correct, if HasHeadingRow:= false; -->

I haven't read your hint
"If HeadingRow, the first [selected] row is not sorted."
j&b
Posts: 184
Joined: Mon Sep 05, 2005 1:35 pm

Re: tableSort sorts all rows except row 0

Post by j&b »

I tried to sort only some rows of a table and my solution runs fine.
Can occur problems ?


1.
unit TableSort;

{$I RV_Defs.inc}

interface
uses
SysUtils, ...,
{$ENDIF}
RVStyle, RichView, RVEdit,
TableSort_Var_jb; //new created and saved in RichViewActions-folder

2.
unit TableSort_Var_jb; //new created
interface
var row1,row2: integer;
implementation
begin
row1:= -1; row2:= -1;
end.


3.
function DoSortCurrentTable(rve: TCustomRichViewEdit; ...
...
begin
Result := False;
GetRangeOfRowsForSorting(table, HasHeadingRow, False, FirstRow, LastRow);

//added
if (row1>-1) and (row2>-1) then begin
FirstRow:= row1; LastRow:= row2; //jb
end;
//end of added

table := CreateSortedTable(rve, table, Column, Ascending, IgnoreCase, DataType,
FirstRow, LastRow);
...


4.
... uses TableSort_Var_jb //added in my program
row1:= 3; row2:= 5; DataType:= (rvsdtString); //(rvsdtNumber);
if CanSortTable(rveTable) then sortCurrentTable(rve, rveTspalte1, richtung, grossKlein,false,DataType);
...
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Answered by email
Post Reply