Xbrowse and empty array

Xbrowse and empty array

Postby Marco Turco » Thu Dec 30, 2010 8: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Xbrowse and empty array

Postby nageswaragunupudi » Thu Dec 30, 2010 9:23 pm

Code: Select all  Expand view

@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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Xbrowse and empty array

Postby Marco Turco » Fri Dec 31, 2010 8: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 83 guests