Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TBrowse source

Status
Not open for further replies.

ZuGa

Programmer
Jul 27, 2005
6
CH
Hello

I have an application built with Clipper 5.2c which I need to run now on XP Prof. As I had troubles generating a database-file I could not solve with FILE statements
in config.nt and so on, I am trying to compile it with xharbour.

Unfortunately it seems that the implementation of TBrowse is slightly different, especially if there are empty lines at the end of the browse window. Does anyone have the source code of the TBrowse class and functions or a link where I can download it, so I could adapt the xharbour source? I am used to programm in Clipper and C (Borland).

I also do not want to miss the opportunity to thank for all tips I got in this forum to help me come so far.

Best regards
Gaby
 
Did you get the CVS version of xHarbour? might be that this (ongoing AFAIK) issue is already solved.
Also don't miss out on the nntp news server of nntp://news.xharbour.com these groups are an invaluable resource for information and help. Not all folders are open, but the rest is very pleasant to have ;-)

BTW, what are you doing to have this errors, as I've not seen issues in my (Clipper-based) TBrowse code running with xHarbour.

HTH
TonHu
 
Hello TonHu

I downloaded the allready compiled libraries and the source from xharbour.org on the 21.7.05. I originally linked the compiled libraries, but to test I also used the source tbrowse.prg-File.
I am not sure if xharbour.tbrowse has an error, it just behaves not the same as my old Clipper V5.2c.

The first problem is I am using tbrowse with arrays and tbColumn:ColorBlock to highlite (grey background) fields that the user can edit.
At the end of the browse I normally have an empty row (editable fields that means an array-element filled with spaces) to insert new records.
I use this code with Clipper 5.2c:
Code:
browse:colorSpec := "W/N,BG/N,BG/W,B/W,RB+/N"
col[LEN(col)]:colorBlock := {|wert| IIF(wert == "", {2,2},{4,3})}
XHarbour.tBrowse draws a grey background on every row below the last entry in my array to tbrowse:nBottom.
Probably this is because in METHOD DrawARow( nRow ) CLASS MyTBrowse the space from last row which has data up to ::rowcount the color is set by this statement if there is a ColorBlock:
Code:
cColor := hb_ColorIndex( ::cColorSpec, ColorToDisp( Eval( ::aColsInfo[ nCol, o_Obj ]:ColorBlock, ::aColsInfo[ nCol, o_Blank ] ), TBC_CLR_STANDARD ) - 1 )
(Code from tbrowse.prg 09/08/2004 - <maurilio.longo@libero.it>)
With Clipper V5.2c all the rows below the last data are black as the screen.
I prefer this, as for me it is more readable. (Perhaps in an other situation I prefer it the other way ;-) .)

The second problems generates a runtime error:
Code:
Error Base/1070 Argument error: == Arguments: ([1] = Type: C Val:          [2] = Type: N Val :    0)
In this case I use tbColumn:ColorBlock to paint certain values with another color:
Code:
browse:colorSpec := "W/N,BG/N,BG/W,B/W,RB+/N"
col[LEN(col)]:colorBlock := {|wert| IIF(wert == 0,{5,5},{2,2})}
I assume that the error is caused by the same statement as above, Probably oBlank fills in Spaces and I try to compare with a Numerical.
I found two workarounds for this problem setting tbrowse:nBottom to the array length (if smaller then window) - or tesing in ColorBlock
Code:
IF VALTYPE(wert) == "N"
.
But I would like to change the behaviour of the tbrowse by building my own one instead of going through all my code (Size of Clipper-exe about 800 KB).

It seems that Itamar Martins Lins Junior stated a similar problem with ColorRect in xHarbour.Unstable.CVS. But he got no answers yet.

I downloaded the xharbour-0.99.50.src.tests.zip and linked the tbrowse.prg ($Id: TBrowse.prg,v 1.3 2004/01/27 03:26:27 fsgiudice Exp $) I found there.
(Originally downloaded tbrowse.prg $Id: tbrowse.prg,v 1.105 2005/05/02 17:05:06 gdrouillard Exp $)
Unfortunately this does not seem to solve my problems. The following are first impressions. I have to test what really happens:
1. The fields are not colored as I like, the selected is BG/N and all others W/N.
2. Sometimes I get crazy behaviour as actual input not at same place as field or colon-delimiters all over the screen.

I understand that xharbour is not yet finished - and probably will never be as there are too many things you can do. But perhaps someone has an idea how I can solve my problem.

I just found the link to the sourceforge.net CVS. I need some time to "compile" the information there.

Best regards
Gaby
 
Hm, I've not used the ColorBlock property of TBrowse much, so I'm not sure about that, but I'm quite sure the compatibility issue you refer to is not yet solved, so that could/would be the one you are waiting for :-(
I'm afraid xHarbour does paint the empty rows of the browser using the colorblock properties like you say. Shouldn't be too hard to fix I hope, but I'd have to work out a working test. (I do have CVS write access)

The IIF(wert == 0, issue is indeed induced by wert not being numerical, and maybe could be replaced by 'IIF(EMPTY(wert),..,..)' or, might that fail or not be what's needed, with a nested IIF( like 'IIF(VALTYPE(wert)="N",IIF(wert=0,..,..),IIF(VALTYPE(wert)="C",..,{other types go here}))'

HTH
TonHu
 
Hello TonHu

In the meantime I got the newest version ( 1.110 Jul 20 09) of tbrowse.prg from the CVS. As you write there were some changes in the part I'm looking. Unfortunately it did not change the behaviour for me. But I found out a way I can live with, although I need to change my program source (only slightly).
Here is what I did:
Code:
METHOD DrawARow( nRow )
// Here we fill the space from last row which has data up to ::rowcount
// Let's find column color once per column            
cColBlanks := Space( ::aColsInfo[ nCol, o_Width ] ) // as is
if ::aColsInfo[ nCol, o_Obj ]:ColorBlock == NIL
   cColor := hb_ColorIndex( ::cColorSpec, ColorToDisp( ::aColsInfo[ nCol, o_DefColor ], TBC_CLR_STANDARD ) - 1 )
else
   cColor := hb_ColorIndex( ::cColorSpec, ColorToDisp( Eval( ::aColsInfo[ nCol, o_Obj ]:ColorBlock, NIL ), TBC_CLR_STANDARD ) - 1 )
// NIL as Parameter to ColorBlock instead of  cColBlanks := Space( ::aColsInfo[ nCol, o_Width ] )
endif
...
DispOut( cColBlanks, cColor )

This lets me test empty rows and color them differently:
Code:
col[ii]:colorBlock := {|wert| IIF(wert == NIL, {2,2},{4,3})}

I am happy with this. I got rid of the error message caused by comparing Strings and Numerics and can color my TBrowse-objects as I like, empty rows being blank. Thank you for you help and tips.
If you or any of your colleagues developing xharbour finds this change usefull too, I would appreciate him to take my change and put it into the source code under his name.
Probably he has to test the code thourougly, I did not find any troubles yet, but I mostly use Strings and Numerics and there are so many different cases.

Best regards
Gaby
 
Well, that NIL return value I haven't compared to Clipper, but maybe you could? (Put up a message like @ 0,0 say valtype(wert), saving and restoring the cursor position) to see what Clipper returns, and then compare and have xHarbour behave the same.
I'd personally check for EMPTY(wert) instead of wert == NIL, just to be comparable in result to your previous sample where you compared 'wert == 0'. Now it depends on the behaveour of TBrowse, and that can change (again) at any time in the future! Better be safe than sorry.

HTH
TonHu
 
Just to notify you, tbrowse has been updated in xHarbour CVS, so you might want to take another try ;-)
The description sounds to be just what you need, AFAICS

HTH
TonHu
 
Hello TonHu

Thanks a lot for this notification. I will surely try it. It sounds as if it solves my problems. Coloring empty rows not with the specified colors but with the default is probably what Clipper is doing.

I found some other thing I do not like in the CVS-implementation of Class TBrowse. And this is still the same in the new version. What is the best way to give you or the authors of this file these informations? I don't believe that this tek-tips forum is the right place.

Best regards
Gaby
 
You can (freely) join the nntp server of xharbour.org at nntp://news.xharbour.org, I use outlook express for that, but any newsreader will do fine, just be sure to select the right (open to all) newsgroups, the ones I read/reply are xharbour and xharbour.Unstable.CVS (<g>)
Several people have writeaccess to CVS but it's not bad to discuss any changes overthere :cool: Major 'concern' is to make xHarbour as Clipper compatible as possible, but without the bugs. So if it's a change that makes tbrowse more compatible with Clipper, it could be implemented soon I guess.
You might get opinions from this group as well though.

HTH
TonHu
(Btw, I have a different nickname on that newsserver)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top