Hello,
Is there a function to fill a array with unique values from a dbf field ?
Ex. STate has : A B C A B B B D
the array should have A,B,C,D
The purpose is in a Xbrowse to filter data with a combo from a
BarGet.
aVals := {}
SET ORDER TO TAG STATEUNQ
DBGOTOP()
DBEVAL( { || AAdd( aVals, FIELD->STATE } )
OrdSetFocus( "STATE" )
DBGOTOP()
do while !Eof()
AADD( aVals, OrdKeyVal() )
OrdSkipUnique()
enddo
INDEX ON STATE TAG STATEUNQ TO TMP MEMORY ADDITIVE UNIQUE
aVals := {}
DBGOTOP()
DBEVAL( { || If( AScan( aVals, FIELD->STATE ) == 0, AAdd( aVals, FIELD->STATE ), nil ) } )
DBGOTOP()
ASORT( aVals )
// You have a normal index on LAST ( not unique )
oCust:OrdSetFocus( "CUST1" )
oCust:GoTop()
do while !oCust:Eof()
AADD( aVals, { oCust:Last, oCust:First } )
oCust:OrdSkipUnique() // !!!! not possible
enddo
// You have a normal index on LAST ( not unique )
oCust:OrdSetFocus( "CUST1" )
oCust:GoTop()
cStrTest := oCust:Last + oCust:First
lUnique := .F.
DO WHILE !oCust:Eof()
IF lUnique = .F.
AADD( aVals, { oCust:Last, oCust:First } )
ENDIF
oCust:Skip(+1)
// OrdSkipUnique() !!!
IF cStrTest = oCust:Last + oCust:First
lUnique := .T.
ELSE
lUnique := .F.
cStrTest := oCust:Last + oCust:First
ENDIF
ENDDO
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 34 guests