Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Appending data to existing file

Posted on 2000-05-09
8
Medium Priority
?
229 Views
Last Modified: 2010-04-04
Appending data to existing file

var

C : String;
D : String;
F : Textfile

begin

C := #$3A+#$3B
D := #$00+#$2A

AssignFile (F, 'mama.txt');
Rewrite(F);
Writeln(F, C);
CloseFile(F);

AssignFile (F, 'mama.txt');
Append(F);
Writeln(F, D);
CloseFile(F);

end;

Every time you append to the 'mama.txt' file it tends to add a #$0D+#$0A which is exactly the same as #$0D, #$0A
From my knowledge its seems to be a [Ctrl+Z] in hex form
Does anyone know how to get rid of that extra #$0D+#$0A so that everything I append to a file is in continous line or continous string.

Ive tried this way

Assignfile (F, 'mama.txt');
Rewrite (F);
Writeln(F, C);
Writeln(F, D);

but it adds a [ASCII 26] which is not what I want

This is the extract from the Delphi Help Manual documenting the Append procedure

'If a Ctrl+Z (ASCII 26) is present in the last 128-byte block of the file, the current file position is set so that the next character added to the file overwrites the first Ctrl+Z in the block. In this way, text can be appended to a file that terminates with a Ctrl+Z.'

does anyone know how to overcome this problem?
0
Comment
Question by:Ben_iti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2792091
hi ben,

writeln appends alraedy$0D$0A
use write instead

#26 is allways added as file-end flag for a textfile, you can't get rid of it, if your filetyp is text.

meikl
0
 
LVL 10

Expert Comment

by:ECollin
ID: 2792093
Hi,

You can use Write instead of WriteLn.
Writeln adds the $0D,$0A at the end of the line.

Emmanuel
0
 
LVL 15

Accepted Solution

by:
simonet earned 240 total points
ID: 2792130

$D + $A  is the End-Of-Line marker. It's what makes the next character appear in the next line of the text file.

$D = CR = carriage return -> Makes the insertion point move to the beginning of the line.
$A = LF = Line feed -> Makes the insertion point move to the next line.

If you want your entire text to appear in a single line, then you can replace the WRITELN() function for WRITE() safely. Otherwise, if each entry is to appear on a different line of text, then you must keep the WRITELN() function.

Yours,

Alex
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:saulite
ID: 2796049
If you don't want #$0D+#$0A in every record, you must use

  write(F,C);
  write(F,D);

Instead of writeLN. It's because writeLN adds $0D+$0A, bur write - don't
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2796463
saulite, do you think that it is fair to repaet comments as answer?

i recommend that you withdraw your answer
0
 

Author Comment

by:Ben_iti
ID: 2816500
im sorry but im going to have to unaccept your answer
thanks

Ben
0
 

Author Comment

by:Ben_iti
ID: 2824912
Congratulations Alex

The points go to you
Your answer included further documentation on the subject.

Thanks

Ben
0
 
LVL 15

Expert Comment

by:simonet
ID: 2825435
Thanks Ben. Good luck!

Alex
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question