elseif ( ::cAlias )->( RddName() ) == "SQLRDD"
DEFAULT ::bKeyNo := ::bBookMark, ;
::bKeyCount := { || ( ::cAlias )->( LastRec() ) }
#define ORDKEYNO() MY_KEYNO(RECNO())
Private nMax_count:=500 // how many recnos for Array save one Time
USE ITEM INDEX ITEM NEW SHARE
// here to save value to a array only 500 records
PRIVATE aDB_ARRAY:={}
PUT_DBARRAY()
...Define a Dialog
...Define a Xbrowse
REDEFINE COLUMN XBROWSE oBrw ID 201 OF oDlg ;
UPDATE
// show ordkeyno() for xbrowse
ADD COLUMN TO xBROWSE oBrw DATA {|| ITEM->(ORDKEYNO())} ;
HEADER "ID" SIZE 20
// you also need to add a Button for reget the value for Array when browse over nMax_count(500)
REDEFINE SBUTTON ID 30 OF oDlg ;
RESOURCE "B_REFRESH" ;
LOOK W97 ;
TEXT POSITION ON_RIGHT ;
TOOLTIP "Reget ordkeyno() for SQLRDD" ;
ACTION ( GET_REFRESH() ,oBrw:REFRESH(),oDlg:UPDATE())
**************************
FUNCTION PUT_DBARRAY(aARRAY,nMAX_COUNT,nNOW_POSITION,lSTART_AT_BOTTOM,lSPECIAL,nOLD_LAST)
MEMVAR aDB_ARRAY
LOCAL I:=0,lDEFAULT_ARRAY:=.T.,J,nPOSI,nLEN
IF ! aARRAY=NIL
lDEFAULT_ARRAY:=.F.
ENDIF
DEFAULT aARRAY:={},nMAX_COUNT:=DEF_SQL_LIMIT_RECORD_COUNT,nNOW_POSITION:=0,lSTART_AT_BOTTOM:=.F.,lSPECIAL:=.F.,nOLD_LAST:=0
IF EMPTY(aARRAY)
aARRAY:={}
ENDIF
DO CASE
CASE nNOW_POSITION#0 .AND. (ASCAN(aARRAY, {|XX| XX[1]=nNOW_POSITION}))=0
CURSORWAIT()
lDEFAULT_ARRAY:=.T.
IF nOLD_LAST=ORDKEYCOUNT() .OR. ORDKEYCOUNT()-nNOW_POSITION<nMAX_COUNT // on bottom
J:=ORDKEYCOUNT()
GO BOTTOM
IF (ASCAN(aARRAY, {|XX| XX[1]=RECNO() }))=0
DO WHILE ! BOF()
AADD(aARRAY , { RECNO() , J-- } )
SKIP -1
IF ++I=nMAX_COUNT
EXIT
ENDIF
ENDDO
ENDIF
ELSE
I:=0
GO TOP
aARRAY:={}
DO WHILE ! EOF() .and. RECNO()#nNOW_POSITION
AADD(aARRAY , { RECNO() , ++I } )
SKIP
ENDDO
nMAX_COUNT:=I+200
DO WHILE ! EOF()
AADD(aARRAY , { RECNO() , ++I } )
SKIP
IF I=nMAX_COUNT
EXIT
ENDIF
ENDDO
ENDIF
CASE lSTART_AT_BOTTOM
J:=ORDKEYCOUNT()
GO BOTTOM
IF (ASCAN(aARRAY, {|XX| XX[1]=RECNO() }))=0
DO WHILE ! BOF()
AADD(aARRAY , { RECNO() , J-- } )
SKIP -1
IF ++I=nMAX_COUNT
EXIT
ENDIF
ENDDO
ENDIF
OTHER
IF (ASCAN(aARRAY, {|XX| XX[1]=RECNO() }))=0
GO TOP
DO WHILE ! EOF()
AADD(aARRAY , { RECNO() , ++I } )
SKIP
IF I=nMAX_COUNT
EXIT
ENDIF
ENDDO
ENDIF
ENDCASE
IF lDEFAULT_ARRAY
aDB_ARRAY:=aARRAY
ENDIF
IF nNOW_POSITION#0
GOTO nNOW_POSITION
ELSE
GO TOP
ENDIF
RETURN NIL
*************************************************************
FUNCTION GET_REFRESH()
STATIC nCNTS:=0
MEMVAR aDB_ARRAY
LOCAL nRECNO:=RECNO()
LOCAL nOLD_LAST:=0
nCNTS++
IF LEN(aDB_ARRAY)>0
nOLD_LAST:=aDB_ARRAY[LEN(aDB_ARRAY)][2]
ENDIF
aDB_ARRAY:={}
MsgRun("Wait","RECNO RECOUNT ", {|| PUT_DBARRAY(@aDB_ARRAY,,nRECNO,.F.,,nOLD_LAST) } )
DBGOTO(nRECNO)
RETURN NIL
**************************
FUNCTION MY_KEYNO(nRECNO , aARRAY , lSPECIAL)
MEMVAR aDB_ARRAY
LOCAL I
DEFAULT aARRAY:=NIL,nRECNO:=0, lSPECIAL:=.F.
IF aARRAY=NIL
IF lSPECIAL
? LEN(aDB_ARRAY)
ENDIF
IF EMPTY(aDB_ARRAY) .OR. nRECNO=0
RETURN 0
ENDIF
IF (I:=ASCAN(aDB_ARRAY , { |XX| XX[1]=nRECNO }))#0
RETURN aDB_ARRAY[I][2]
ENDIF
ELSE
IF EMPTY(aARRAY) .OR. nRECNO=0
RETURN 0
ENDIF
IF (I:=ASCAN(aARRAY , { |XX| XX[1]=nRECNO }))#0
RETURN aARRAY[I][2]
ENDIF
ENDIF
RETURN 0
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 25 guests