Page 1 of 1

XBrowse and add column

Posted: Sat May 24, 2008 3:46 pm
by Marco Turco
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.

Posted: Thu May 29, 2008 2:37 pm
by nageswaragunupudi
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.

Code: Select all

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.

Posted: Thu May 29, 2008 2:55 pm
by Antonio Linares
Marco,

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

Posted: Thu May 29, 2008 3:15 pm
by Antonio Linares
Marco,

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

Code: Select all

#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> )

Posted: Sat May 31, 2008 1:05 pm
by Marco Turco
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

Posted: Sun Jun 01, 2008 3:02 pm
by Antonio Linares
Marco,

This should be the way to do it:

Code: Select all

#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

Posted: Mon Jun 02, 2008 8:41 am
by Marco Turco
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
..
..

Posted: Mon Jun 02, 2008 1:19 pm
by Antonio Linares
Marco,

The clause AUTOSORT applies for all the columns created by the @ <r>,<c> XBROWSE or REDEFINE XBROWSE command. Example :

Code: Select all

   @ 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:

Code: Select all

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

Posted: Thu Jun 05, 2008 4:32 pm
by Marco Turco
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.

Posted: Tue Jun 10, 2008 6:28 pm
by Antonio Linares
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:

Code: Select all

    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

Posted: Wed Jun 11, 2008 6:13 pm
by Marco Turco
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.

Posted: Fri Jun 27, 2008 12:51 pm
by Antonio Linares
Marco,

With TXBrowse version 8.06 you can write

Code: Select all

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


instead of

Code: Select all

    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.