Page 1 of 1

xBrowse and empty array

Posted: Fri Jun 06, 2008 9:19 am
by Marco Turco
Hi,
the xBrowse crash when the array is empty.

Is there any solution ? With the old tcbrowse all runs fine.

Sample code:

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

function Main()

DEFINE BITMAP oGreen FILENAME "16green.bmp"
DEFINE BITMAP oRed FILENAME "16red.bmp"

aNames:=array(0,5)
** aadd(aNames,{1,"Marc1","4th Floor","Queens House",oRed})
** aadd(aNames,{2,"Marc2","4th Floor","Queens House",oRed})
** aadd(aNames,{3,"Marc3","4th Floor","Queens House",oGreen})
** aadd(aNames,{4,"Marc4","4th Floor","Queens House",oGreen})

DEFINE dialog oDlg TITLE "xBrowse tests" FROM 5,5 TO 40,80

@1,1 XBROWSE oBrw ARRAY aNames of oDlg AUTOSORT

ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 1;
HEADER "Num" SIZE 30 LEFT order 2

ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 2;
HEADER "Name" SIZE 80 order 2

oBrw:CreateFromCode()

ACTIVATE dialog oDlg

Empty array

Posted: Fri Jun 06, 2008 1:36 pm
by ukoenig
Hello Marco,

after creating a array, you have to add a
empty element like => ASIZE( YOUR_ARRAY, 0 )
otherwise you have a problem with xBrowse

Best regards :lol:

Uwe

Posted: Fri Jun 06, 2008 2:33 pm
by Marco Turco
Hi Uwe,
do you means something like this:

aNames:=array(0,5)
aadd(aNames,{"","","","","})

in order to add at least one record in the array ?

Xbrowse and Arrays

Posted: Fri Jun 06, 2008 2:48 pm
by ukoenig
Hello Marco,

yes, before you open xBrowse,
you have to add 1 empty array-element.
The function ASIZE works only with 1 dimension-arrays.

A sample with 7 xbrowse-Rows and 2 Chars ( 2 Col's ).

PRIVATE aBRCOLOR[7][2]

aBRCOLOR[1] := { "1", "Black" }
aBRCOLOR[2] := { "2", "White" }
aBRCOLOR[3] := { "3", "Blue" }
aBRCOLOR[4] := { "4", "Green" }
aBRCOLOR[5] := { "5", "Red" }
aBRCOLOR[6] := { "6", "Yellow" }
aBRCOLOR[7] := { "7", "Magenta" }

A empty array with 2 Chars ( 2 Col's ):

aBRCOLOR := {}

Before you open xBrowse !!!
---------------------------------
AADD( aBRCOLOR, { " ", " " } )

Best regards

Uwe :lol:

Posted: Tue Jun 10, 2008 6:04 pm
by Antonio Linares
Marco,

To start with the row should contain at least one row. XBrowse uses this row to examine and store information about datatype, default picture, default alignment, etc. Then from the ON INIT clause of the Dialog or Window, resize the array to 0.

Example:

Code: Select all

    aNames:={}
    aadd(aNames,{1,"Marc","4th Floor","Queens House", 2 })

    DEFINE dialog oDlg TITLE "xBrowse Empty Array" SIZE 600,300 PIXEL

   @ 10,10 XBROWSE oBrw COLUMNS 1, 2 ;
      HEADERS "Num",  "Name" ;
      COLSIZES 30, 80 ;
      ARRAY aNames of oDlg SIZE 280,130 PIXEL AUTOSORT

   oBrw:CreateFromCode()
   ACTIVATE dialog oDlg ON INIT ( ASize( aNames, 0 ) )