Skip to content

OrdDescend() + OrderScope() and Eof()/Bof() problem #579

@Karl1155

Description

@Karl1155

This sample switches to the descend view before it tries to set a OrderScope

Note: the sample uses instead of

OrdScope(TOPSCOPE, "R")
OrdScope(BOTTOMSCOPE, "B")

the wrong order:

OrdScope(TOPSCOPE, "B") // Note: must be "R" !
OrdScope(BOTTOMSCOPE, "R") // Note: must be "B" !

ordKeycount() returns correctly 0
but Eof() returns .f. instead of .t.
but Bof() returns .f. instead of .t.

FUNCTION OrdDescAndOrdScope() AS VOID 
LOCAL cDBF, cPfad, cIndex   AS STRING 
LOCAL aFields, aValues AS ARRAY 
LOCAL i AS DWORD  


    RddSetDefault ( "DBFCDX" ) 
    
    cPfad := "D:\test\" 
 
	cDBF := cPfad + "Foo"
	cIndex := cPfad + "Foox" 
	
	FErase ( cIndex + IndexExt() )
		
	aFields := { { "LAST" , "C" , 20 , 0 } 	} 
	
	aValues := { "g6" , "o2", "g2" , "g1" , "g3" , "g5" , "B1" , "b2" , "p", "q" , "r" , "s" }	
	
	// ------------
	
	DbCreate( cDBF , AFields)
	DbUseArea( ,,cDBF )		

	FOR i := 1 UPTO ALen ( aValues )
		DbAppend() 
		FieldPut ( 1 , aValues [ i ] )
	NEXT
	
	DbCreateOrder ( "ORDER1" , cIndex , "upper(LAST)" , { || Upper ( _Field->LAST) } )
	DbCloseArea()
	
	// --------------
	
	DbUseArea( ,,cDBF )
	DbSetIndex ( cIndex )
	DbSetOrder ( 1 ) 
	
	OrdDescend ( , , TRUE )  // switch to descend view

	OrdScope(TOPSCOPE, "B")     // Note: must be "R" !
	OrdScope(BOTTOMSCOPE, "R")  // Note: must be "B" !
	
	? "OrdKeyCount()" , OrdKeyCount()
	?     
	
	// -------------	
	
	DbGoTop()            
	? Bof() , Eof()  // both return .f. !


    DO WHILE ! Eof()
    	? FieldGet ( 1 ) 
    	DbSkip ( 1 )
    	
    ENDDO 	
           
   
    DbGoTop()       
    ? Bof() , Eof() // both return .f. !
    
    DbGoBottom()       
    ? Bof() , Eof() // both return .f. !


	DbCloseArea() 
	
	RETURN 		 	

regards
Karl-Heinz

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions