FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse and empty array
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Xbrowse and empty array
Posted: Thu Dec 30, 2010 08:14 PM

Hi,
there are some problems using xbrowse with an array that changes its elements number until to come an empty array.
The problem is that when it come empty it lost the original header structure.

In the attached self-contained sample, the xbrowse start with some elements, then if you press the "RemoveData" button, a new empty array will be assigned and as you can see the xbrowse lost its headers.

This is due to the samearray method. I also tried to change this method returning always .t. in a test.
In this situation the problem is that the headers remains after setting the empty array but when I try to assign a new fill array pressing the "GetData" button then the xbrowse always displayed empty.

Any solution ?

Thanks in advance.

include "FiveWin.ch" #include "xbrowse.ch"

function Main() local oBtn, oDlg,aNames,aArray, oBrw2, oCol

aArray:=BrwGetData()

DEFINE dialog oDlg TITLE "xBrowse tests" FROM 5,5 TO 70,100

@1,1 XBROWSE oBrw2 ARRAY AARRAY OF oDlg

ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 1; HEADER "Num"
    SIZE 80 ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 2;
    HEADER "Type" SIZE 200

oBrw2:CreateFromCode()

@10,10 BUTTON "GetData" OF ODLG; ACTION
    (aArray:=BrwGetData(),oBrw2:SetArray(aArray),oBrw2:Refresh())

@12,10 BUTTON "RemoveData" OF ODLG; ACTION
    (aArray:=array(0,2),oBrw2:SetArray(aArray),oBrw2:Refresh())

ACTIVATE dialog oDlg return

Function BrwGetData() local aArray

aArray:=array(0,4) aadd(aArray,{1,"RED"}) aadd(aArray,{2,"GREEN"})
aadd(aArray,{2,"GREEN"}) aadd(aArray,{1,"RED"}) return(aArray)
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse and empty array
Posted: Thu Dec 30, 2010 09:23 PM
Code (fw): Select all Collapse
@10,10 BUTTON "GetData" OF ODLG; ACTION
(oBr2:aArrayData :=BrwGetData(),oBrw2:Refresh())

@12,10 BUTTON "RemoveData" OF ODLG; ACTION
(ASize( oBrw2:aArrayData, 0 ),oBrw2:Refresh())
Regards



G. N. Rao.

Hyderabad, India
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Xbrowse and empty array
Posted: Fri Dec 31, 2010 08:04 AM

It runs fine. Thank you.
I only suggest to apply the following fix directly to the xbrowse class from line 3810.

     if SameArrayStruct( Self, aData ) //.or. empty( ::aArrayData )
        if len(aData)=0
            aSize(::aArrayData,0)
        else
            ::aArrayData = aData
        endif
         ::Refresh()
        return nil
     else
        ::aCols  := {}
        lReSet   := .t.
     endif
Best Regards,



Marco Turco

SOFTWARE XP LLP

Continue the discussion