Board index » delphi » Re: Problem - export

Re: Problem - export


2006-02-19 01:30:29 AM
delphi47
Hoi Katarina
You need to repost your question on the Borland news server to make
everybody see it and possibly answer your question.
Take a look here:
<tinyurl.com/8m5nw>
which links to
<delphi.wikicities.com/wiki/Delphi_Newsgroups>
 
 

Re: Problem - export

I made a program for export from Table.DBF to Table.TXT.
The anomaly was appear on text , you can see how to like:
img148.imageshack.us/img148/5534/look9lh.jpg
Code:
var S: string; i: integer; F:Textfile;
begin
//Query1(ID, Org, Surname, Name)
AssignFile(F, 'tekst.txt');
rewrite(F);
S := '';
Query1.First;
while not Query1.EOF do
begin
for i := 0 to Query1.FieldCount - 1 do
S := s+Query1.Fields[i].AsString+#9;
S := s+#13#10;
Query1.Next;
end;
writeln(F,s);
CloseFile(f);
end;
I looked Google and Help for copy, pos, substring....it doesn't
result.
THANKS IN ADVANCE,
Katarina
 

Re: Problem - export

Opa, I didn't know to do this.... I will visit link... THANK YOU VERY
MUCH, Riki. :)
 

Re: Problem - export

The file is fine. Notepad displays tabs in increments of 8 characters.
When the value in the column to the left (I assume it is the person's
last name) is long the first name is pushed to the right to the next
multiple of eight characters.
--
Bill Todd (TeamB)
 

Re: Problem - export

On 18 Feb 2006 11:20:00 -0800, Katarina writes:
Quote
Opa, I didn't know to do this.... I will visit link... THANK YOU VERY
MUCH, Riki. :)
That is a quite common mistake first time you post here. I find about 20 to
30 new posters every week that falls into the same problem.
Anyway I see you have reposted and already got an answer.
Doei Riki Wiki
 

Re: Problem - export

You may like to try my alterations if you want to view the file with notepad
(Unchanged lines start with '>')
On 18 Feb 2006 11:15:37 -0700, "Katarina" <XXXX@XXXXX.COM>writes:
Quote
Code:
var S, S2: string; i: integer; F:Textfile;
begin
//Query1(ID, Org, Surname, Name)
AssignFile(F, 'tekst.txt');
rewrite(F);
S := '';
Query1.First;
while not Query1.EOF do
begin
for i := 0 to Query1.FieldCount - 1 do
BEGIN
S2 := Query1.Fields [i].AsString;
IF (I = 3) AND (Length (S2) < 8) THEN
S2 := S2 + #9; // add a tab char if the sting is too short
S := s+S2+#9;
END;
Quote
S := s+#13#10;
Query1.Next;
end;
writeln(F,s);
CloseFile(f);
end;
 

Re: Problem - export

Thank you very much, Allan, this is a right answer. :))))
However, there are a another answer, have a look(elegant solution):
for i := 0 to Query1.FieldCount - 1 do
begin
if (i=0) then s:=s+copy(Query1.Fields[i].AsString+'
',1,8);
if (i=1) then s:=s+copy(Query1.Fields[i].AsString+'
',1,6);
if (i=2) then
...............
end;
:)
Too, thanks to Bill and Rikki ;).