EinTerraner
Technical User
This error occurs after several runs of the exchange procedure. Sometimes it fires after 2 runs or even after 10 rounds.
I have a table, sorted by group-number, line-number and subtext-number (like "1.7.3") all are numeric
The result should look something like this
before moving -> after moving ->
To move a group (or a row/sub-row), you just have to swap the corresponding numbers. I have the following code for this.
and to reinsert those two xchanged groups/Lines
any idea what i'm doing wrong?
I have a table, sorted by group-number, line-number and subtext-number (like "1.7.3") all are numeric
The result should look something like this
before moving -> after moving ->
To move a group (or a row/sub-row), you just have to swap the corresponding numbers. I have the following code for this.
Code:
WITH THIS && MyGrid.DataMove(Tc_Line as Object)
** Use a mirror-cursor because .RecordSource might have a active filter
USE DBF(.RecordSource) ALIAS(.TmpAlias) IN SELECT(.TmpAlias) SHARED AGAIN
** Lo_Line.BEDGRUP = Destination
** Tc_Line.BEDGRUP = Source
SELECT * FROM (.TmpAlias) ;
INTO CURSOR (.SrcAlias) READWRITE ; && fetch source group
WHERE Lo_Line.BEDGRUP == BEDGRUP
SELECT * FROM (.TmpAlias) ;
INTO CURSOR (.DstAlias) READWRITE ; && fetch target group
WHERE Tc_Line.BEDGRUP == BEDGRUP
REPLACE BEDGRUP WITH Lo_Line.BEDGRUP ; && Rename target group to source group
IN (.DstAlias) ;
FOR .t.
REPLACE BEDGRUP WITH Tc_Line.BEDGRUP ; && Rename source group to target group
IN (.SrcAlias) ;
FOR .t.
BLANK IN (.TmpAlias) ; && wipe both groups
FOR INLIST(BEDGRUP, Lo_Line.BEDGRUP, Tc_Line.BEDGRUP)
Lc_Done = .t.
Code:
** Replace moved Group back to table
** recycle blank lines.
** otherwise table becomes large
IF Lc_Done
GO TOP IN (.SrcAlias)
DO WHILE !EOF(.SrcAlias)
SELECT(.SrcAlias)
SCATTER NAME Lo_Line MEMO
SELECT(.TmpAlias)
LOCATE FOR EMPTY(BEDNUMM)
IF !FOUND(.TmpAlias)
APPEND BLANK IN (.TmpAlias)
ENDIF
GATHER NAME Lo_Line MEMO
SKIP IN (.SrcAlias)
ENDDO
GO TOP IN (.DstAlias)
DO WHILE !EOF(.DstAlias)
SELECT(.DstAlias)
SCATTER NAME Lo_Line MEMO
SELECT(.TmpAlias)
LOCATE FOR EMPTY(BEDNUMM)
IF !FOUND(.TmpAlias)
APPEND BLANK IN (.TmpAlias)
ENDIF
GATHER NAME Lo_Line MEMO
SKIP IN (.DstAlias)
ENDDO
ENDIF
any idea what i'm doing wrong?