Page 1 of 2

Append SDF error

PostPosted: Thu Nov 04, 2010 7:38 pm
by Marc Vanzegbroeck
Hello,

I have a program that import some information from a text-file with the append from SDF command.
From time to time it doesn't import all records.
Here is the test-code:
Code: Select all  Expand view
#INCLUDE "fivewin.CH"
REQUEST DBFCDX
FUNCTION test()
   local vstruct:={}
   RDDSETDEFAULT("DBFCDX")
   dbstructuur:={}
   aadd(vstruct,{'LINE','C',199,0})
   dbcreate('import.tmp',vstruct)
   use ('import.tmp') new
   appe from test.txt sdf
   go top
   browse()
RETURN nil
 


Here is the text-file that can't be imported completly. It allways stops at the same record, and I can't find out why.
http://www.vms.be/FWTest/test.txt
Can someone try this?
My last record is allways:
<Artikelcode>SCTATC</Artikelcode>

I use FW710.

Thanks,
Marc

Re: Append SDF error

PostPosted: Fri Nov 05, 2010 12:36 am
by driessen
Marc,

To my opinion, your TEST.TXT-file is an XML-file.
I don't think you can add data to your DBF-file by using SDF.

Re: Append SDF error

PostPosted: Fri Nov 05, 2010 8:04 am
by Marc Vanzegbroeck
Michel,

This file is indead an xml-file. But this is also a text-file. So why can't he import it, and why always on the same line? It's only with this file. Most other xml-files give no problem.
I head this problem also before when importing prg-files. Most of them are imported complete, other not...

I also try it with clipper52 and also with foxpro, and then the file is imported without any problem!!!

Regards,
Marc

Re: Append SDF error

PostPosted: Fri Nov 05, 2010 4:11 pm
by James Bott
Marc,

It is working fine here. I copied the text.txt from within IE. I wonder if there is some special character after the last line you are getting. Take a look at the original file with a hex editor, or zip it and send it to me at jbott at compuserve dot com.

I am using FWH 10.8/xHarbour.

Regards,
James

Re: Append SDF error

PostPosted: Fri Nov 05, 2010 6:48 pm
by Marc Vanzegbroeck
James,

File send.

Regards,
Marc

Re: Append SDF error

PostPosted: Fri Nov 05, 2010 7:19 pm
by James Bott
For those interested in the solution, I found that if I appended a space to the end of each line in the text.txt file, then APPENDed it, it works fine. I have no idea why this is needed, but it is a viable workaround.

Regards,
James

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 10:38 am
by Enrico Maria Giordano
Can you make a little sample and try it with Clipper? If it were a real bug I would report it to the developers list.

EMG

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 11:42 am
by Marc Vanzegbroeck
Enrico,

Like I already explained in previous message, in clipper52 it work just fine.

Here is the link of the text-file in zip format.
http://www.vms.be/FWTest/test.zip

Regards,
Marc

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 12:16 pm
by Euclides
Marc,
The fields in TEST.TXT are separated by hex "0A".
If they are before treted by an text editor and saved, the separator becomes "0D0A" and then it works right. It could be a xHarbour error.
Only tested with xHarbour Compiler build 1.0.0 (SimpLex)
Regards, Euclides

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 12:28 pm
by Enrico Maria Giordano
Marc Vanzegbroeck wrote:Enrico,

Like I already explained in previous message, in clipper52 it work just fine.

Here is the link of the text-file in zip format.
[url]http::/www.vms.be/FWTest/test.zip[/url]

Regards,
Marc


Thank you. I'm looking at the sample...

EMG

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 12:55 pm
by Enrico Maria Giordano
Ok, I reported it to the developers list. I tried to fix the problem but it's really too much complicated for me, sorry.

EMG

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 3:16 pm
by Marc Vanzegbroeck
Euclides,

Thanks for the info.

I use now this code as workaround.

Code: Select all  Expand view
#INCLUDE "fivewin.CH"
REQUEST DBFCDX
FUNCTION test()
   local vstruct:={}
   memowrit('test.tmp',strtran(memoread('test.txt'),chr(10),chr(13)+chr(10)))
   RDDSETDEFAULT("DBFCDX")
   dbstructuur:={}
   aadd(vstruct,{'LINE','C',199,0})
   dbcreate('import.tmp',vstruct)
   use ('import.tmp') new

   appe from test.tmp sdf
   go top
   browse()
RETURN nil
 


Regards,
Marc

Re: Append SDF error

PostPosted: Sat Nov 06, 2010 5:36 pm
by James Bott
Euclides,

The fields in TEST.TXT are separated by hex "0A".
If they are before treted by an text editor and saved, the separator becomes "0D0A" and then it works right. It could be a xHarbour error.


When I look at the file the fields ARE separated by 0D0A already, so I don't think that is the problem.

James

Re: Append SDF error

PostPosted: Tue Nov 09, 2010 8:25 am
by Enrico Maria Giordano
The bug has been fixed by Vicente Guerra in the xHarbour CVS.

EMG

Re: Append SDF error

PostPosted: Tue Nov 09, 2010 2:53 pm
by James Bott
Enrico,

Thanks for getting that done.

James