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 » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Read a DBF file
Read a DBF file [message #8221] Tue, 20 February 2007 13:21 Go to next message
forlano is currently offline  forlano
Messages: 1189
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

here is a simple code snippet that print on the screen the content of a DBF file by using the DbfStream stream.
Luigi

#include <Core/Core.h>
#include <TCore/dbf.h>

using namespace Upp;

CONSOLE_APP_MAIN
{   int i; 
	DbfStream dbf;
	if(!dbf.Open("C:\\upp\\out\\MSC8\\club.dbf", false) ) {
		return;
	}
	int NFields = dbf.GetFieldCount();
	while(dbf.Fetch()) {
		String text;
	 	for (i=0; i<NFields; i++) {
			text << dbf[i] << " # ";
	 	}
		text << "\n";
		Cout() << text;
	} 
    dbf.Close();
}
Re: Read a DBF file [message #8481 is a reply to message #8221] Tue, 13 March 2007 14:43 Go to previous messageGo to next message
porto is currently offline  porto
Messages: 51
Registered: March 2007
Member
Please, help newbie Rolling Eyes
When building example, i got:
----- Core ( GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (1 / 5)
----- TCore ( GCC DEBUG DEBUG_FULL BLITZ WIN32 ) (2 / 5)
BLITZ: dbf.cpp globcfg.cpp xmlparse.cpp help.cpp CalcType.cpp CalcNode.cpp CalcBasic.cpp datafile.cpp databas
	e.cpp datatest.cpp
In file included from C:\_personal\upp\uppsrc\TCore\/TCore.h:9,
                 from C:\_personal\upp\uppsrc\TCore\dbf.cpp:1,
                 from C:/_personal/upp/out/TCore/MINGW.Debug_full\$blitz.cpp:3:
C:\_personal\upp\uppsrc\TCore\/template.h: In member function `T* Upp::PtrValue<T>::Get(const Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:120: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: In static member function `static T* Upp::PtrValue<T>::Extract(con
	st Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:121: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: At global scope:
C:\_personal\upp\uppsrc\TCore\/template.h:408: error: expected type-name
C:\_personal\upp\uppsrc\TCore\/template.h:411: error: expected type-name
util.cpp
In file included from C:\_personal\upp\uppsrc\TCore\/TCore.h:9,
                 from C:\_personal\upp\uppsrc\TCore\util.cpp:1:
C:\_personal\upp\uppsrc\TCore\/template.h: In member function `T* Upp::PtrValue<T>::Get(const Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:120: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: In static member function `static T* Upp::PtrValue<T>::Extract(con
	st Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:121: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: At global scope:
C:\_personal\upp\uppsrc\TCore\/template.h:408: error: expected type-name
C:\_personal\upp\uppsrc\TCore\/template.h:411: error: expected type-name
TCore_init.icpp
In file included from C:\_personal\upp\uppsrc\TCore\/TCore.h:9,
                 from C:\_personal\upp\uppsrc\TCore\TCore_init.icpp:1:
C:\_personal\upp\uppsrc\TCore\/template.h: In member function `T* Upp::PtrValue<T>::Get(const Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:120: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: In static member function `static T* Upp::PtrValue<T>::Extract(con
	st Upp::Value&)':
C:\_personal\upp\uppsrc\TCore\/template.h:121: error: `::IsNull' has not been declared
C:\_personal\upp\uppsrc\TCore\/template.h: At global scope:
C:\_personal\upp\uppsrc\TCore\/template.h:408: error: expected type-name
C:\_personal\upp\uppsrc\TCore\/template.h:411: error: expected type-name
TCore: 12 file(s) built in (0:17.42), 1451 msecs / file, duration = 17438 msecs

There were errors. (0:17.48)

What is wrong?
P.S. I use built in MinGW ver. of UPP (2007.1 rc3) on WinXP.
Re: Read a DBF file [message #8488 is a reply to message #8481] Tue, 13 March 2007 16:06 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1189
Registered: March 2006
Location: Italy
Senior Contributor
porto wrote on Tue, 13 March 2007 14:43

Please, help newbie ...
What is wrong?
P.S. I use built in MinGW ver. of UPP (2007.1 rc3) on WinXP.


Hi,

I cannot help you. As you I started with MinGW but after some struggle I switched to MSC8 compiler. I strongly suggest you to do the same as soon as possible. At the moment I've not a MinGW in my system.

Luigi
Re: Read a DBF file [message #8491 is a reply to message #8488] Tue, 13 March 2007 18:08 Go to previous messageGo to next message
victorb is currently offline  victorb
Messages: 78
Registered: December 2005
Location: Nice, France
Member
I think the issue is with TCore that contains experimental code that might be sync'ed with other code.

I was able to compile it with MinGW & XP by doing the following modifs:
l 120, 121 (add "UPP")
	T        *Get(const Value& v)       { return UPP::IsNull(v) ? 0 : Rep::Cast(v.GetVoidPtr())->Get(); }
	static T *Extract(const Value& v)   { return UPP::IsNull(v) ? 0 : Rep::Cast(v.GetVoidPtr())->Get(); }


l 407-411 (comment out)
//template <class T>
//class UPP::RefCon;

//template <class T>
//class UPP::RefPtr; 


Hope this help

[Updated on: Tue, 13 March 2007 18:11]

Report message to a moderator

Re: Read a DBF file [message #8492 is a reply to message #8221] Tue, 13 March 2007 18:22 Go to previous messageGo to next message
porto is currently offline  porto
Messages: 51
Registered: March 2007
Member
Thanks a lot for your answers guys! Very Happy
Your answers have really helped me.

[Updated on: Tue, 13 March 2007 19:57]

Report message to a moderator

icon9.gif  Re: Read a DBF file [message #9173 is a reply to message #8221] Thu, 19 April 2007 22:46 Go to previous messageGo to next message
Sbleck is currently offline  Sbleck
Messages: 16
Registered: April 2007
Location: Brazil
Promising Member

Hi,

Please, HELP other newbie !

#include <Core/Core.h>
#include <Core/dbf.h>

using namespace Upp;

CONSOLE_APP_MAIN
{   int i; 
	DbfStream dbf;
	if(!dbf.Open("C:\\Temp\\numteus\\cntr.dbf", false) ) {
		return;
	}
	int NFields = dbf.GetFieldCount();
	while(dbf.Fetch()) {
		String text;
	 	for (i=0; i<NFields; i++) {
			text << dbf[i] << " # ";
	 	}
		text << "\n";
		Cout() << text;
	} 
    dbf.Close();
}


I tried to put dbf.h in any possible place (under C:\upp), but nothing could produce other result than THIS:

----- CtrlLib ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (1 / 9)
----- CtrlCore ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (2 / 9)
----- RichText ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (3 / 9)
----- Draw ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (4 / 9)
----- Core ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (5 / 9)
----- plugin/bmp ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (6 / 9)
----- plugin\z ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (7 / 9)
----- plugin\png ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (8 / 9)
----- DBF_Reader ( CONSOLE MAIN MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (9 / 9)
main.cpp
C:\upp\MyApps\DBF_Reader\main.cpp(2) : fatal error C1083: Cannot open include file: 'Core/dbf.h': No such fil
e or directory
DBF_Reader: 1 file(s) built in (0:01.20), 1203 msecs / file, duration = 1234 msecs

There were errors. (0:01.78)

Anibody with good will could explain how should I configure "these" include files, to get rid of these problems ? ANY HELP could be GREATLY appreciated, of course...

Regards,
Sven
Re: Read a DBF file [message #9174 is a reply to message #9173] Thu, 19 April 2007 22:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
#include <plugin/dbf/dbf.h>

(see examples/DbfView)

Mirek
icon7.gif  Re: Read a DBF file [message #9298 is a reply to message #8221] Thu, 26 April 2007 00:27 Go to previous messageGo to next message
Sbleck is currently offline  Sbleck
Messages: 16
Registered: April 2007
Location: Brazil
Promising Member

Hi Mirek,

I added the plugin/dbf package to the assembly I was working and now it runs ok...

----- CtrlLib ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (1 / 10)
----- plugin\dbf ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (2 / 10)
dbf.cpp
plugin\dbf: 1 file(s) built in (0:05.85), 5859 msecs / file, duration = 6234 msecs
----- CtrlCore ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (3 / 10)
----- RichText ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (4 / 10)
----- Draw ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (5 / 10)
----- Core ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (6 / 10)
----- plugin/bmp ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (7 / 10)
----- plugin\z ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (8 / 10)
----- plugin\png ( CONSOLE MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (9 / 10)
----- DBF_Reader ( CONSOLE MAIN MSC8 DEBUG DEBUG_FULL BLITZ WIN32 MSC ) (10 / 10)
main.cpp
DBF_Reader: 1 file(s) built in (0:02.95), 2953 msecs / file, duration = 3015 msecs
Linking...
C:\upp\out\MSC8.Console.Debug_full\DBF_Reader.exe (3506176 B) linked in (0:13.95)

OK. (0:33.93)


Is there any way to check what packages are needed and what could be removed ? I noted that could be possible to have many things (exported from another projects) inside one assembly, that not need to be inside of it...

Other doubt was correlated to the output. Should I have any other configuration to obtain the results, when operating in console mode ?

C:\upp\out\MSC8.Console>dir
 Volume in drive C is ADMMAN
 Volume Serial Number is 5475-89A7

 Directory of C:\upp\out\MSC8.Console

25/04/2007  19:23    <DIR>          .
25/04/2007  19:23    <DIR>          ..
25/04/2007  19:21           835.584 DBF_Reader.exe
               1 File(s)        835.584 bytes
               2 Dir(s)     527.302.656 bytes free

C:\upp\out\MSC8.Console>DBF_Reader

C:\upp\out\MSC8.Console>


Regards,
Sven


Re: Read a DBF file [message #9338 is a reply to message #9298] Sat, 28 April 2007 08:10 Go to previous message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Not really, this seems OK.

Mirek
Previous Topic: Using dual-screen
Next Topic: examples\HomeBudget
Goto Forum:
  


Current Time: Sat Jun 15 17:01:12 CEST 2024

Total time taken to generate the page: 0.03260 seconds