xBrowse and empty array

Post Reply
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

xBrowse and empty array

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

Marco Turco
SOFTWARE XP LLP
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Empty array

Post 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
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
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

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

Marco Turco
SOFTWARE XP LLP
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Xbrowse and Arrays

Post 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:
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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply