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 #11076 is a reply to message #10804] Sat, 18 August 2007 11:05 Go to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
mrjt wrote on Mon, 30 July 2007 06:05

"name", "filter" is the correct format. For example:
fs.Type("Text Files", "*.txt");

Although ".txt" will also work.




Sorry about messed example...

This should solve some of problems, please test:

#include <CtrlLib/CtrlLib.h>
#include <plugin/dbf/dbf.h>

using namespace Upp;

struct DbfView : public TopWindow {
	Splitter s;
	ArrayCtrl table;
	ArrayCtrl row;
	DbfStream dbf;

	void EnterRow();
	void Perform();

	typedef DbfView CLASSNAME;

	DbfView();
};

String FormatField(const DbfStream::Field& f)
{
	return f.name + Format(" (%c%d)", f.type, f.width);
}

void DbfView::EnterRow()
{
	row.Clear();
	if(!dbf.Fetch(table.GetKey()))
		return;
	for(int i = 0; i < dbf.GetFieldCount(); i++)
		row.Add(FormatField(dbf.GetField(i)), dbf[i]);
}

void DbfView::Perform()
{
	FileSel fs;
	LoadFromFile(fs);
	fs.AllFilesType();
	fs.Type("dbf", "*.dbf");
	if(!fs.ExecuteOpen("DBF..")) return;
	StoreToFile(fs);
	if(!dbf.Open(~fs))
		Exclamation("Can't open input file");
	table.AddKey();
	for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
		table.AddColumn(FormatField(dbf.GetField(i)));
	while(dbf.Fetch()) {
		Vector<Value> v;
		v.Add(dbf.GetPos());
		for(int i = 0; i < min(4, dbf.GetFieldCount()); i++)
			v.Add(dbf[i]);
		table.Add(v);
	}
	Run();
}

DbfView::DbfView()
{
	s.Set(table, row);
	s.SetPos(7000);
	Add(s.SizePos());
	Sizeable().Zoomable();
	table.WhenEnterRow = THISBACK(EnterRow);
	row.AddColumn("Column");
	row.AddColumn("Value", 2);
}

GUI_APP_MAIN
{
	SetDefaultCharset(CHARSET_WIN1252);
	Ctrl::NoLayoutZoom();

	DbfView().Perform();
}


I am moving this to the "library" area...



Mirek
 
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:11:40 CEST 2025

Total time taken to generate the page: 0.04093 seconds