Page 1 of 1

xBrowse how to show 1 DBF in 2 browser with diff. indexes ?

Posted: Wed Mar 16, 2016 3:24 pm
by ukoenig
Hello,

I must show 2 browser with different indexes
the first UNIQUE ( index by < names > ) the second ( Index by < names + articel > )
is that possible ?

The problem :
before I used a customer.dbf and a article.dbf with relation on customer-name.
It works fine but It can be, that the custumer is not included in custumer.dbf anymore after some years
to make it possible to select the customer and control the articles.
I have to use the included names from the articel.dbf using UNIQUE for the customer-selection
to show the related articles in browser 2.

I noticed only the 2. index is used
Browser 1 and browser 2 are using the same index

My test to split the customer.dbf in 2 browser.

USE customer NEW SHARED ALIAS CUSTOMER VIA 'DBFCDX'
ORDCREATE( ,"CUST1", "UPPER(LAST)", ;
{|| UPPER(LAST) } , .T. ) // .T. = UNIQUE IGNORED !!!
ORDCREATE( ,"CUST2", "UPPER(LAST)", ;
{|| UPPER(LAST) } , .F. )

My test

Image

Code: Select all

#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

//-------------------------------------- 

FUNCTION MAIN()
local oDlg, oBrw1, oBrw2, oFont1, oFont2, oBtn1

DEFINE FONT oFont1 NAME "TAHOMA" SIZE 0,-14
DEFINE FONT oFont2 NAME "TAHOMA" SIZE 0,-18

SETBALLOON( .T. ) // Balloon shape required for tooltips

DEFINE DIALOG oDlg SIZE 590, 540 PIXEL COLOR 255 ;
TITLE "Testing UNIQUE in XBrowse" ;
FONT oFont1

// ------

USE customer NEW SHARED ALIAS CUSTOMER VIA 'DBFCDX'
ORDCREATE( ,"CUST1", "UPPER(LAST)", ;
        {|| UPPER(LAST) } , .T. )   // .T. = UNIQUE
ORDCREATE( ,"CUST2", "UPPER(LAST)", ;
        {|| UPPER(LAST) } , .F. )   

DBSELECTAREA( "CUSTOMER" )
("CUSTOMER")->(DBSETORDER( "CUST1" ))
("CUSTOMER")->( DBGOTOP() )
 
@ 15, 15 XBROWSE oBrw1 ;
COLUMNS 'Last', 'Age', 'Value' ;
OF oDlg ;
SIZE 220, 112 PIXEL ;
COLSIZES 195, NIL, 95 ;
PICTURES nil, '999.99 %', '999999.99' ;
ALIAS 'CUSTOMER' ;
CELL LINES AUTOCOLS AUTOSORT 

oBrw1:bClrStd           := { || If( oBrw1:KeyNo() % 2 == 0, ;
                            { If( ( oBrw1:cAlias )->( Deleted() ), 255, 0 ), 15329747 }, ;
                            { If( ( oBrw1:cAlias )->( Deleted() ), 255, 0 ), 16053482 } ) }
oBrw1:bClrSel           :=  ;
oBrw1:bClrSelFocus  := { || { If( ( oBrw1:cAlias )->( Deleted() ), 255, 0 ), 14935039 } }
oBrw1:nRecSelColor  := 14201187 

WITH OBJECT oBrw1
      :CreateFromCode()
END

 
// ----------------- BROWSER 2

DBSELECTAREA( "CUSTOMER" )
("CUSTOMER")->(DBSETORDER( "CUST2" ))
("CUSTOMER")->( DBGOTOP() )

@ 140, 15 XBROWSE oBrw2 ;
      COLUMNS 'Last', 'Age', 'Value' ;
      OF oDlg ;
      SIZE 220, 112 PIXEL ;
      COLSIZES 195, NIL, 95 ;
      PICTURES nil, '999.99 %', '999999.99' ;
      ALIAS 'CUSTOMER' ;
      CELL LINES AUTOCOLS AUTOSORT 

oBrw2:bClrStd           := { || If( oBrw2:KeyNo() % 2 == 0, ;
                            { If( ( oBrw2:cAlias )->( Deleted() ), 255, 0 ), 15329747 }, ;
                            { If( ( oBrw2:cAlias )->( Deleted() ), 255, 0 ), 16053482 } ) }
oBrw2:bClrSel           :=  ;
oBrw2:bClrSelFocus  := { || { If( ( oBrw2:cAlias )->( Deleted() ), 255, 0 ), 14935039 } }
oBrw2:nRecSelColor  := 14201187 


WITH OBJECT oBrw2

      :CreateFromCode()

END
 
// ------------

@ 240, 250 BTNBMP  oBtn1 OF oDlg ;
SIZE 37, 20 PIXEL 2007 ;
BORDER CENTER ROUND ;
PROMPT "&Exit" ;
ACTION oDlg:End()
oBtn1:bClrGrad := { | lMouseOver | If( ! lMouseOver,;
        { { 0.5, 14342911, 16119295 }, { 0.5, 16119295, 14342911 } }, ;
        { { 0.5, 14277043, 16053482 }, { 0.5, 16053482, 14277043 } } ) }
oBtn1:cToolTip =  { "Exit" + CRLF + "test","EXIT", 1, CLR_BLACK, 14089979 }
oBtn1:SetColor( 0, )

DLG_BRUSH(oDlg, 2, 16182746, "Wall.bmp")

ACTIVATE DIALOG oDlg CENTERED

RELEASE FONT oFont1
RELEASE FONT oFont2

RETURN NIL

// --------------------------------

STATIC FUNCTION DLG_BRUSH(oDlg, nStyle, nColor, cBmp, cImage)
LOCAL oBrush, oImage
LOCAL aRect := GETCLIENTRECT( oDlg:hWnd ) 

IF nStyle = 1
    DEFINE BRUSH oBrush COLOR nColor
ENDIF
IF nStyle = 2
    DEFINE BRUSH oBrush FILENAME cBmp
ENDIF
IF nStyle = 3
    DEFINE IMAGE oImage FILE cImage
    oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) ) 
    oImage:End()
ENDIF
oDlg:SetBrush( oBrush )

RELEASE BRUSH oBrush

RETURN NIL
 
any idea ?

best regards
Uwe :?:

Re: xBrowse how to show 1 DBF in 2 browser with diff. indexes ?

Posted: Wed Mar 16, 2016 5:02 pm
by Marco Augusto
you can open de same database in two diferenta areas

use customer index cust1 shared new alias data1
use customer index cust2 shared new alias data2

sele data1
xbrowse
sele data2
xbrowse

Re: xBrowse how to show 1 DBF in 2 browser with diff. indexes ?

Posted: Wed Mar 16, 2016 6:33 pm
by ukoenig
Marco,

thank You very much.
The problem was, to include / change the logic of my existing code.
Belongs to my extra Network-library and some other functions.
It seems I got it working now.

best regards
Uwe :D

Re: xBrowse how to show 1 DBF in 2 browser with diff. indexes ?

Posted: Wed Mar 16, 2016 6:52 pm
by TimStone
If you use database objects ( so much easier ), you simply open two different objects. It's a very easy solution. Also, you don't have to track "areas" ...