oCol:bStrData with oBrw filled by array?

oCol:bStrData with oBrw filled by array?

Postby JC » Wed Sep 10, 2008 4:06 pm

How I can exchange this code to works... when oBrw is filled by an array!
Code: Select all  Expand view  RUN
oCol := ::oCol( "cHeader" )
::getWidth( replicate( "B", len( eval( oCol:bStrData ) ) ), oCol:oDataFont )

With this, the fivewin returns an error like this: Class 'Nil' no exported method BSTRDATA
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby nageswaragunupudi » Wed Sep 10, 2008 5:00 pm

When we set an array for xbrowse, it only keeps in mind the array element number. The browse creates all codeblocks like bEditValue, bStrData, bOnPostEdit and also calculates the width required, aligment depending on the data type and such other things while executing the createfromcode().

In fact xbrowse does the same calculation you have given above on its own and decides the width before activation of the browse. So that we are relieved of all these complex calculations. There is really no need for us to go through the calculation of width by ourselves.

Still for academic interest, if you want to see what the codeblocks the xbrowse constructs, you may call oCol:Adjust() and then use bStrData.

My personal advice is let the xbrowse do its job of all these mundane calculations. It does its job fairly well and in most cases, better than us. I find it better to tell xbrowse what to browse and let it do the rest.

Let us tell what column number to browse and the picture and header. It does the rest.

If you give your full code, perhaps I can explain it better
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10660
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby JC » Thu Sep 11, 2008 11:42 am

Nages,

Thanks for your tip... I will try to use ::adjust() after reallocate the headers and values of columns!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby nageswaragunupudi » Thu Sep 11, 2008 12:00 pm

JC wrote:Nages,

Thanks for your tip... I will try to use ::adjust() after reallocate the headers and values of columns!


Ok
But I wonder why do you need to do it at all? Xbrowse does exactly the same calculations you are trying to do. May I know your purpose, if you dont mind ? I am just curious
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10660
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby JC » Thu Sep 11, 2008 12:36 pm

Ok
But I wonder why do you need to do it at all? Xbrowse does exactly the same calculations you are trying to do. May I know your purpose, if you dont mind ? I am just curious


Dear Nages,

This is my source:
Code: Select all  Expand view  RUN
    oBrw := TXBrowse():new( oDlg )
             oBrw:SetArray( aDataArray, .T., 2 )

             oBrw:aCols[1]:cHeader    := ""
             oBrw:aCols[1]:nWidth     := 30
             oBrw:aCols[1]:setCheck( { "IMG_CHECK_ON", "IMG_CHECK_OFF" } )
             oBrw:aCols[1]:cSortOrder := NIL

             oBrw:aCols[2]:cHeader       := "Code"
             oBrw:aCols[2]:nWidth        := 50
             oBrw:aCols[2]:nDataStrAlign := AL_CENTER

             oBrw:aCols[3]:cHeader       := "Name"
             oBrw:aCols[3]:nWidth        := 330
             oBrw:aCols[3]:nDataStrAlign := AL_LEFT

After this, I want to adjust the with of columns where the xBrowse truncate the information because the new size of columns headers.

When I execute the ::adjust(), this error returns to me:
Code: Select all  Expand view  RUN
Application
===========
   Path and name: C:\app.EXE (32 bits)
   Size: 1,430,528 bytes
   Time from start: 0 hours 1 mins 7 secs
   Error occurred at: 11/09/2008, 08:42:23
   Error description: Error BASE/1004  Class: 'NIL' has no exported method: NESCAPEMENT
   Args:
     [   1] = U   

Stack Calls
===========
   Called from:  => NESCAPEMENT(0)
   Called from: C:\FWH\source\classes\xbrowse.prg => FONTESC(8124)
   Called from: C:\FWH\source\classes\xbrowse.prg => TXBRWCOLUMN:HEADERWIDTH(6339)
   Called from: C:\FWH\source\classes\xbrowse.prg => TXBRWCOLUMN:ADJUST(6191)
   Called from: C:\FWH\source\classes\xbrowse.prg => TXBROWSE:ADJUST(748)
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Error xBrowse

Postby ukoenig » Thu Sep 11, 2008 1:03 pm

Hello JC

oBrw:aCols[1]:cSortOrder := NIL

I think :
< cSortOrder > has to be the header-string of a col.

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

Re: Error xBrowse

Postby JC » Thu Sep 11, 2008 1:06 pm

ukoenig wrote:Hello JC

oBrw:aCols[1]:cSortOrder := NIL

I think :
< cSortOrder > has to be the header-string of a col.

Regards
Uwe :lol:


Uwe,
You are right! But, when You want to "disable" the seek order for one column is necessary to set cSetOrder to Nil... like the testxbr3.prg sample!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Thu Sep 11, 2008 1:09 pm

My doubt is: How I can get the real size of a value column of xBrowse filled with an array?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: Error xBrowse

Postby nageswaragunupudi » Thu Sep 11, 2008 1:27 pm

ukoenig wrote:Hello JC

oBrw:aCols[1]:cSortOrder := NIL

I think :
< cSortOrder > has to be the header-string of a col.

Regards
Uwe :lol:


cSortOrder can be nil if the column is not to be sorted.

If we want the xbrowse to sort the column,

a) for arrays cSortOrder should be the Array Element Number ( Numeric ) on which the data is to be sorted.

b) for any RDD, cSortOrder should be the name of the IndexTag

c) For RecordSet it should be the fieldname on which we want the data to be sorted.

d) For Database Objects like TDataBase or TData, the name used by the SetOrder method of the object

If we dont want the xbrowse to help us with auto-sorting and we insist on having our own way, then still the old method of defining the bLClickHeader action block is still available but thats a tedious way of coding.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10660
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby nageswaragunupudi » Thu Sep 11, 2008 2:22 pm

Mr JC

I have executed your code as it is ( just substituted bitmap names). The widths are okay.

Now, to know more about how xbrowse auto-calculates the widths: If we ourselves specify the width xbrowse does not do any calculations and blindly adopts the width we specify. If we have not specified the widths, it evaluates the bStrData ( while executing the method CreateFromCode ) and calculates the width of the evaluated value in pixels and adds bitmap width if necessaray. Finally it takes the maximum of data width, Header width and footer width. Normally these calculations give satisfactory results.

The problem with Arrays is that the browse calculates the widths on the basis of the data in the first row of the array. In case the data in the first row are smaller in width, values in the next rows are truncated. In case of RDD and RecSets this problem does not arise "normally" if we specify the column name.

So when we browse arrays it becomes necessary for us to specify the widths manually in our program. But the problem is that we have to specify the widths in Pixels and we do not know the exact fit.

I wish someday xbrowse provides a way to specify the widths in number of characters ( easy for us to specify ) than pixels and the xbrowse calculating the width on the basis of the number of characters.

Till then I adopt a work around. I always know how many characters are to be shown. So I invariably give picture clauses. For text I give a picture clause like 'XXXXX'. Now all my array browses are fit exactly.

for example I would write

@ 0,0 XBROWSE oBrw ;
HEADERS '', 'Code', 'Name' ;
PICTURE NIL, REPLICATE( 'X', 5 ), REPLICATE( 'X', 30 ) ;
ARRAY aDataArray AUTOSORT AUTOCOLS ..... etc.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10660
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby JC » Thu Sep 11, 2008 5:23 pm

I have used this solution for my problem... but, I don't know if it's is the best way to do!

Code: Select all  Expand view  RUN
cHeader := "anything_for_header" <- Only for exhibition because this is generated automatically!!
oCol    := ::oCol( cHeader )

nLenHeader := ::getWidth( replicate( "B", len( cHeader ) ) )
nLenData   := ::getWidth( replicate( "B", len( ::aArrayData[1, oCol:nArrayCol] ) ), oCol:oDataFont )

oCol:nWidth := max( nLenHeader, nLenData )
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests