FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XBrowse and add column
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM

XBrowse and add column

Posted: Sat May 24, 2008 03:46 PM

Hi to all,
I doing some tests about xbrowse to evaluate a migration from the "old" tcbrowse and I did find a problem using the ADD COLUMN command that generate an error.

This is a self-contained code that show the problem:

include "FiveWin.ch"

include "xbrowse.ch"

function Main()
aNames:={}

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

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

@1,1 XBROWSE oBrw ARRAY aNames

ADD COLUMN TO oBrw DATA ARRAY ELEM 1

ADD COLUMN TO oBrw DATA ARRAY ELEM 2

ACTIVATE dialog OWND

I think the problem is into the xbrowse.ch that translate the command using the tcbrowse functions instead of the new xbrowse function.

Is there any solution ?
I need to manage single "ADD COLUMN"
so I can't assign the columns immediatly when I call the XBROWSE command.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

XBrowse and add column

Posted: Thu May 29, 2008 02:37 PM
Mr Marco


>
I think the problem is into the xbrowse.ch that translate the command using the tcbrowse functions instead of the new xbrowse function.
>

You are right. Till FWH rectifies the command translate, I advise you to add new columns the way I do.
oCol := oBrw:AddCol()
oCol:nArrayCol := 1  // the column number


The above code is equivalent to
ADD COLUMN TO oBrw DATA ARRAY ELEM 1
xBrowse takes care of minimum formatting requirements, whatever the data type.
Regards



G. N. Rao.

Hyderabad, India
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Thu May 29, 2008 02:55 PM

Marco,

We are going to provide a modified xbrowse.ch asap, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Thu May 29, 2008 03:15 PM
Marco,

Please replace this command inside include/xbrowse.ch, thanks

#command ADD [ COLUMN ] [<oCol>]  TO [ XBROWSE ] <oBrw> [ DATA ] ARRAY ;
            [ AT <nAt> ] ;
            [ <el: ELM, ELEM, ELEMENT> <elm> ] ;
            [ <tit: TITLE, HEADER> <cHead> [ <oem: OEM, ANSI, CONVERT>] ];
            [ <clr: COLORS, COLOURS> <uClrFore> [,<uClrBack>] ] ;
            [ ALIGN ] [ <al: LEFT, CENTERED, RIGHT> ] ;
            [ <wid: WIDTH, SIZE> <nWidth> [ PIXELS ] ] ;
            [ <pict: PICT, PICTURE> <cPicture> ] ;
            [ <bit: BITMAP> ] ;
            [ <edit: EDITABLE> ] ;
            [ ON EDIT <bOnPostEdit> ] ;
            [ MESSAGE <cMsg> ] ;
            [ WHEN <uWhen> ] ;
            [ VALID <uValid> ] ;
            [ ERROR [MSG] [MESSAGE] <cErr> ] ;
            [ <lite: NOBAR, NOHILITE> ] ;
            [ <idx: ORDER, INDEX, TAG> <nOrder> ] ;
            => ;
            [<oCol> :=] XbrwAddColumn( <oBrw>, ;
            If(<.oem.>, OemToAnsi(<cHead>), <cHead>), ;
            <elm>, <cPicture>, ;
            [<uClrFore>], [<uClrBack>], ;
            [ Upper( <(al)> ) ], <nWidth>, <.bit.>, ;
            <.edit.>, <bOnPostEdit>, <cMsg>, <{uWhen}>, <{uValid}>, <cErr>, <.lite.>, <nOrder>, <nAt> )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM

XBrowse and add column

Posted: Sat May 31, 2008 01:05 PM

Thanks Antonio.
It runs now, but there is still a problem using bitmaps.

In this sample code I try to display the 5th Array element that is a bitmap but it is displayed as "Object" in the browse.

Did I forget somethings ?

Full code with executable and bitmaps available at:

www.softwarexp.co.uk/beta/xtest.zip

Thanks.

include "FiveWin.ch"

include "xbrowse.ch"

function Main()

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

aNames:={}
aadd(aNames,{1,"Marc","4th Floor","Queens House",oRed})
aadd(aNames,{2,"Marc","4th Floor","Queens House",oRed})
aadd(aNames,{3,"Marc","4th Floor","Queens House",oGreen})
aadd(aNames,{4,"Marc","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

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

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

ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 5;
    HEADER "Status" SIZE 80 BITMAP

oBrw:CreateFromCode()

ACTIVATE dialog oDlg
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Sun Jun 01, 2008 03:02 PM
Marco,

This should be the way to do it:
#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

    local oGreen, oRed, oBrw, oDlg, aNames
/*
    DEFINE BITMAP oGreen FILENAME "16green.bmp"
    DEFINE BITMAP oRed FILENAME "16red.bmp"
*/
    aNames:={}
    aadd(aNames,{1,"Marc","4th Floor","Queens House", 2 }) //oRed})
    aadd(aNames,{2,"Marc","4th Floor","Queens House", 2 }) //oRed})
    aadd(aNames,{3,"Marc","4th Floor","Queens House", 1 }) //oGreen})
    aadd(aNames,{4,"Marc","4th Floor","Queens House", 1 }) //oGreen})

    DEFINE dialog oDlg TITLE "xBrowse tests" SIZE 600,300 PIXEL

    @ 10,10 XBROWSE oBrw ARRAY aNames of oDlg SIZE 280,130 PIXEL

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

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

    ADD COLUMN TO XBROWSE oBrw ; // DATA ARRAY ELEM 5;
        HEADER "Status" SIZE 80 BITMAP // BITMAP syntax has not effect now. Will be fixed in 8.06

        WITH OBJECT oBrw:oCol( "Status" )
           :bBmpData := { || oBrw:aRow[ 5 ] }
           :AddBmpFile( "16green.bmp" )
           :AddBmpFile( "16red.bmp" )
        END


    oBrw:CreateFromCode()

    ACTIVATE dialog oDlg

 return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM

XBrowse and add column

Posted: Mon Jun 02, 2008 08:41 AM
Solved, thanks.

There is a problem also with the AUTOSORT paramet.
It doen't runs if I use the ADD COLUMN command to define the column (see code below).

It is not urgent for me but I advise you about this problem.

..
..

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

ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 2;
HEADER "Name" SIZE 80
..
..
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Mon Jun 02, 2008 01:19 PM
Marco,

The clause AUTOSORT applies for all the columns created by the @ <r>,<c> XBROWSE or REDEFINE XBROWSE command. Example :
   @ 10,10 XBROWSE oBrw ;
      COLUMNS 1, 2 ;
      HEADERS "Num",  "Name" ;
      COLSIZES 30, 80 ;
      ARRAY aNames of oDlg SIZE 280,130 PIXEL AUTOSORT


To specify sorting while adding a column, specify the clause ORDER <cnOrder> IN THE ADD command. Example:
    ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 2; 
        HEADER "Name" SIZE 80 ORDER 2
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM

XBrowse and add column

Posted: Thu Jun 05, 2008 04:32 PM

You are right. It runs fine. Thanks.

In the meantime I have found other two bugs :D
1) using the SORT 2 command in a bitmap column an error appairs
2) using the :ToExcel method in a browse with a bitmap column exist then the bitmap column is not exported (correct !!) but the header of the bitmap column is exported moving all headers on the right.

I have found some sample turn-around for these errors
but a fix in the xbrowse class will be appreciated.

Thanks.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Tue Jun 10, 2008 06:28 PM
Marco,

> In the meantime I have found other two bugs

Its working fine with FWH 8.05 here

>
1) using the SORT 2 command in a bitmap column an error appairs
>

ORDER not SORT. If you want a bitmap column to be sorted, there should be some value in the bEditValue.
Here is the right way to code, in the above sample:
    ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 5 ;
        HEADER "Status" SIZE 80 BITMAP ORDER 5 


        WITH OBJECT oBrw:oCol( "Status" )
           :bBmpData := { || oBrw:aRow[ 5 ] }
           :AddBmpFile( "16green.bmp" )
           :AddBmpFile( "16red.bmp" )
        END


>
2) using the :ToExcel method in a browse with a bitmap column exist then the bitmap column is not exported (correct !!) but the header of the bitmap column is exported moving all headers on the right.
>

Working fine with 8.05
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM

XBrowse and add column

Posted: Wed Jun 11, 2008 06:13 PM

It is all right now about bitmap sorting but could you pls. explain me better about the cnOrder valute to assign with ORDER ?
Is it the column number or what is it ? If I assign to cnOrder a random value I can always sorting that column pressing the header.

With reference to the excel export I have the following error:

Application

Path and name: K:\TEST\SEND\XTEST.EXE (32 bits)
Size: 1,579,008 bytes
Time from start: 0 hours 0 mins 5 secs
Error occurred at: 06/11/08, 19:58:43
Error description: Error Excel.Application:ACTIVESHEET:COLUMNS/0 S_OK: _STYLE
Args:
[ 1] = C Comma [0]

Stack Calls

Called from: win32ole.prg => TOLEAUTO:_STYLE(0)
Called from: XBROWSE.PRG => TXBROWSE:TOEXCEL(0)
Called from: XTEST.PRG => (b)MAIN(39)

Do I need an updated xbrowse class ?

However I enclosed in a self-contained sample at www.softwarexp.co.uk/beta/xtest2.zip my current xbrowse class (from the May 2008 Fwh class folder) and the sample code that generate this error pressing the "Excel" button.

Thanks.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

XBrowse and add column

Posted: Fri Jun 27, 2008 12:51 PM
Marco,

With TXBrowse version 8.06 you can write

    ADD COLUMN TO XBROWSE oBrw ARRAY ; 
        HEADER "Status" ;
        BITMAP BMPDATA 5 IN "16green.bmp", "16red.bmp" ORDER 1


instead of

    ADD COLUMN TO XBROWSE oBrw DATA ARRAY ELEM 5 ; 
        HEADER "Status" SIZE 80 BITMAP ORDER 5 


        WITH OBJECT oBrw:oCol( "Status" ) 
           :bBmpData := { || oBrw:aRow[ 5 ] } 
           :AddBmpFile( "16green.bmp" ) 
           :AddBmpFile( "16red.bmp" ) 
        END


as required with earlier versions.

Excel export works perfectly with English versions. We are trying to make it compatible with international versions in other language. Please try again with version 8.06. Your feedback with details about the language of your installation will help us to make the functionality fully universal.
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion