xBrowse and empty array

xBrowse and empty array

Postby Marco Turco » Fri Jun 06, 2008 9: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Empty array

Postby ukoenig » Fri Jun 06, 2008 1: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Marco Turco » Fri Jun 06, 2008 2: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Xbrowse and Arrays

Postby ukoenig » Fri Jun 06, 2008 2: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby Antonio Linares » Tue Jun 10, 2008 6: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:
Code: Select all  Expand view
    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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests