Re: nmnntp
From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 10/07/04
- Next message: Maarten Wiltink: "Re: Popup Hints in Treeview"
- Previous message: AlanGLLoyd: "Re: Popup Hints in Treeview"
- In reply to: Dominic van Berkel: "nmnntp"
- Next in thread: Jamie: "Re: nmnntp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 7 Oct 2004 15:51:49 +0200
"Dominic van Berkel" <dovabe@hotmail.com> wrote in message
news:dc19e990.0410070040.5f7d2d9f@posting.google.com...
> I'm trying to make a newsreading (usenet) program with delphi, and
> till now (i've only just come to connecting to the host) all is right.
> Still, has anyone got some advice for me? cos my delphi programs
> always seem to have some trouble being right, eg the write-command (to
> a textfile). I just can't get it working.
Let's focus on writing text to a file first. There are those who might
think you don't really want to write an involved network client program
without being able to do such basic things.
The classical way is with a text file, writing lines of text into it.
var
output: text;
line: string;
begin
assign(output, 'output.txt');
rewrite(output);
writeln(output, line);
close(output);
end;
The help file has useful things to say about "text", "assign",
"rewrite", "writeln", and "close", including their recommended new
names and a few other things to use instead when you want to do
slightly different things.
You can also write non-string variables into a file, but I suggest
that you don't. Without a way to read your files back, the only way
to use them is to open them in a text or hex editor and of the two,
the text editor is easiest on the eyes.
This is for files that contain lines of text. You can also build
a long string buffer and write it to a file all at once; type
"TStream", press F1, read help. If and when you understand what
streams are for, proceed to TStringStream.
Some objects may be able to write themselves to a file. This is a
useful technique: it lets you concentrate on the data it contains
and the behaviour it exhibits, and some of its behaviours may have
names like WriteToFile and ReadFromFile. The object may be problem
domain oriented, or it may just be a convenient intermediate step
in the process of getting your data on disk. Think of an XML document
tree object; you can keep your data however you want and fill the XML
object when needed, or use it throughout to keep your data in during
manipulation.
As an alternative to files, you can store data in a database. That
adds structure to the storage space, instead of requiring you to
"flatten" your data every time it goes to disk.
Groetjes,
Maarten Wiltink
- Next message: Maarten Wiltink: "Re: Popup Hints in Treeview"
- Previous message: AlanGLLoyd: "Re: Popup Hints in Treeview"
- In reply to: Dominic van Berkel: "nmnntp"
- Next in thread: Jamie: "Re: nmnntp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|