I still did some changes :
1. File < PRODUCT.dbf > got a index on field < PRODUCTO >
2. Added the vars < cUP > and < cDOWN >
Building the button-array, I get the products of < UP > and < DOWN > as well.
OLD :
@ 10, 220 BTNBMP PROMPT "UP" FLAT SIZE 40,30 PIXEL OF oDlg ;
WHEN nFirstBtn >= 4 ;
ACTION ( nFirstBtn := Max( 0, nFirstBtn - 8 ), oDlg:Update() )
@ 45, 220 BTNBMP PROMPT "DOWN" FLAT SIZE 40,30 PIXEL OF oDlg ;
WHEN nFirstBtn + 8 < Len( aVariantes ) ;
ACTION ( nFirstBtn := Min( Len( aVariantes ) - 8, nFirstBtn + 8 ), ;
oDlg:Update() )
NEW :
@ 450, 530 BTNBMP PROMPT "UP" FLAT SIZE 80, 50 PIXEL OF oDlgMain ;
ACTION ( SETPRODUCT( cUP ), oDlgMain:Update() )
@ 505, 530 BTNBMP PROMPT "DOWN" FLAT SIZE 80, 50 PIXEL OF oDlgMain ;
ACTION ( SETPRODUCT( cDOWN ), oDlgMain:Update() )
Reaching EOF or BOF of table shows a message.
The defined UP and DOWN-values :
- Code: Select all Expand view
STATIC FUNCTION SETPRODUCT( cProduct )
LOCAL nLen
aVariantes := VA->( FW_DbfToArray( "ALLTRIM(DESC1),PRECIO,VARIANTE", { || FIELD->PRODUCTO = cProduct } ) )
nLen := Len( aVariantes )
ASize( aVariantes, Max( 8, 4 * Max( 1, Ceiling( nLen / 4 ) ) ) )
AFill( aVariantes, { "", "", "" }, nLen + 1 )
nFirstBtn := 0
// get UP-value
// ------------------
VA->( DBSEEK(cProduct) )
VA->( DBSKIP(-1) )
IF VA->( BOF() )
MsgAlert( "BOF of table !!!", "Attention" )
ELSE
cUP := FIELD->PRODUCTO
ENDIF
// get DOWN-value
// ----------------------
VA->( DBSEEK(cProduct) )
DO WHILE FIELD->PRODUCTO = cProduct
VA->( DBSKIP(+1) )
ENDDO
IF VA->( EOF() )
MsgAlert( "EOF of table !!!", "Attention" )
ELSE
cDOWN := FIELD->PRODUCTO
ENDIF
RETURN NIL
regards
Uwe