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: Fri Jun 06, 2008 09:19 AM

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
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Empty array
Posted: Fri Jun 06, 2008 01:36 PM

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

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
xBrowse and empty array
Posted: Fri Jun 06, 2008 02:33 PM

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 ?

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Xbrowse and Arrays
Posted: Fri Jun 06, 2008 02:48 PM

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:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
xBrowse and empty array
Posted: Tue Jun 10, 2008 06:04 PM
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:
    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 ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion