|
From: Gary K. <gbo...@ya...> - 2006-12-14 19:21:36
|
Maybe try the latest 3.x version and see if that works for you.
Gary
Igor Vitorio Custodio <ig...@bo...> wrote:
Hello!
I'm having problems with memo fields.
See the code and explanation about the problem below:
I have a lot of DBF files that I need to port to Postgres, but first I
need to read it.
I downloaded the 2.0.0 version of XBase and I'm developing in Slackware
Linux with gcc 3.4.6. I installed and runned the example programs fine.
So, I started to code a program, using the example4.cpp like a example, to
port my DBF file to the database, first writting the result at STDOUT.
This is the code:
// test.cpp
#include
int main()
{
xbShort rc;
xbShort clientNumber, clientRegist, docNumber, chkSum;
xbLong memoSize ;
char buf[40000];
xbXBase x;
xbDbf MyFile( &x );
if(( rc = MyFile.OpenDatabase( "MYFILE.DBF" )) != XB_NO_ERROR )
{
cout << "\nError opening file rc = " << rc << "\n";
exit(1);
}
docNumber = MyFile.GetFieldNo( "NUMMEDICO" );
clientRegist = MyFile.GetFieldNo( "PRONTUARIO" );
clientNumber = MyFile.GetFieldNo( "NUMCLIENTE" );
chkSum = MyFile.GetFieldNo( "CHKSUM" );
cout << "\n Position of NUMCLIENTE -> " << clientNumber
<< " Type: " << MyFile.GetFieldType( clientNumber );
cout << "\n Position of NUMMEDICO -> " << docNumber
<< " Type: " << MyFile.GetFieldType( docNumber );
cout << "\n Position of PRONTUARIO -> " << clientRegist
<< " Type: " << MyFile.GetFieldType( clientRegist ); // memo!
cout << "\n Position of CHKSUM -> " << chkSum
<< " Type:" << MyFile.GetFieldType( chkSum );
rc = MyFile.GetFirstRecord();
while( rc == XB_NO_ERROR )
{
rc = MyFile.GetNextRecord();
memoSize = MyFile.GetMemoFieldLen( clientRegist );
cout << " Memo Size = " << memoSize ;
xbShort erro = MyFile.GetMemoField( 1, 40000, buf, F_SETLK );
cout << " Error cod. " << erro;
switch (erro)
{
case XB_INVALID_FIELDNO:
cout << "\nAn invalid field number was used";
break;
case XB_NOT_MEMO_FIELD:
cout << "\nNot a memo field";
break;
case XB_NO_MEMO_DATA:
cout << "\nNo memo data exists";
break;
case XB_INVALID_BLOCK_NO:
cout << "\nInternal error, notify tech support";
break;
case XB_SEEK_ERROR :
cout << "\nDisk Error";
break;
case XB_READ_ERROR:
cout << "\nDisk Error";
break;
case XB_NO_ERROR:
cout << "\nNo Error";
break;
}
if (MyFile.MemoFieldsPresent())
cout << "\nTHERE IS a memo register!" << endl;
else
cout << "\nTHERE ISN'T memo register!" << endl;
}
if(( rc = MyFile.PackDatabase( F_SETLKW )) != XB_NO_ERROR )
cout << "\nError packing database rc = " << rc;
else
cout << "\n\n\n\nDatabase packed.\n";
MyFile.ExclusiveUnlock(); /* unlock the files */
MyFile.CloseDatabase(); /* close database */
return 0;
}
I compile without problens!
But see the result at STDOUT:
Position of NUMCLIENTE -> 0 Type: N
Position of NUMMEDICO -> 2 Type: N
Position of PRONTUARIO -> 1 Type: M
Position of CHKSUM -> 3 Type:C
(...) // a lot of ...
Memo Size = 0 Error cod. -134
No memo data exists
THERE IS a memo register!
(...)
Can anyone explain why MyFile.MemoFieldsPresent() say that there is a memo
field but MyFile.GetMemoField and MyFile.GetMemoFieldLen() don't ????
Best regards
--
---- ------- --------
~ Igor Vitório Custódio (igorvc)
' v ' PLACA - ENC 03 - UFSCar
/ / \ \ E-Mail: ig...@bo...
/ ( ) \ http://www.igor.uni.cc
^ ` ~ ' ^ Linux User: #322156
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
XDB-users mailing list
XDB...@li...
https://lists.sourceforge.net/lists/listinfo/xdb-users
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business. |