Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » bug in DbfView example
Re: bug in DbfView example [message #10801 is a reply to message #10778] Mon, 30 July 2007 05:23 Go to previous messageGo to previous message
mr_ped is currently offline  mr_ped
Messages: 826
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
I found out some more problems...

1)
	while(dbf.Fetch()) {
		Vector<Value> v;
		for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
			v.Add(dbf[i]);
		table.Add(v);
	}


Does add all record to table, but it does skip over deleted rows, what does cause inconsistency with later

void DbfView::EnterRow()
{
	row.Clear();
	if(!dbf.Fetch(table.GetCursor()))
		return;


So you get wrong detailed view in such case, and whole index will be moved by -1 to -n (number of deleted rows).

Quick fix:
	if(!dbf.Open(~fs))
		Exclamation("Can't open input file");
	for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
		table.AddColumn(FormatField(dbf.GetField(i)));
	for (int ri = 0; ri < dbf.GetRowCount(); ++ri ) {
		Vector<Value> v;
		if(!dbf.Fetch(ri)) v.Add("DELETED");
		else for(int i = 0; i < min(4, dbf.GetFieldCount()); i++) v.Add(dbf[i]);
		table.Add(v);
	}


edit: ARGH, I used the local "i" two times... not very good programming practice... Very Happy ... so I changed it to "ri".

This will add also deleted rows to the main table, so the cursor is always right than.




2)
I'm unable to show correct czech characters no matter what charset I try. (in my desperation I tried all 26 of them)
My code to convert looks like this (in void DbfView::EnterRow):
...
	for(int i = 0; i < dbf.GetFieldCount(); i++) {
		Value val = dbf[i];
		if ( val.GetType() == STRING_V ) {
			String valtxt = val.ToString();
			//WString valwtxt = ToUnicode(valtxt, CHARSET_WIN1250);
			WString valwtxt = ToUnicode(valtxt, dbf.GetCharset() );
			row.Add(FormatField(dbf.GetField(i)), valwtxt);
		} else {
			row.Add(FormatField(dbf.GetField(i)), val);
		}


U++ 2007.1, Kubuntu 6.10
Charset for IDE: UTF-8
Charset for application: tried UTF-8, win1250, ISO8859_2, CP852, MJK

No luck so far... I will try it later on windows, maybe there some charset will work??

@Mirek: is it possible the result on windows will be different?

(P.S. I'm trying to do my first commercial project in U++, something very small, ugly, and it should work with DBF files from FoxPro ... the final application will be for Windows, but so far I'm developing just some base and toying around, so I'm staying in my main system so far ... that's the reason why I'm so into this example, I really must be sure I understand the DBF plugin enough Smile )

[Updated on: Mon, 30 July 2007 05:25]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: bug? : operator "!" for "bool"
Next Topic: howto access SVN please?
Goto Forum:
  


Current Time: Wed Jun 25 21:20:43 CEST 2025

Total time taken to generate the page: 0.03906 seconds