Re: nmnntp

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 10/07/04


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



Relevant Pages

  • Re: Disc image of dual layer DVD
    ... I didn't change any of the settings on Disk ... Just put the disc in and clicked "New ... This is where you choose if the DMG file is to ... One way to be sure is to check using a hex editor. ...
    (uk.comp.sys.mac)
  • Re: Tcl Web Service with Authorization kills Tcl
    ... from tclhttpd, but for whatever reason it didn't work when was ... used to write the POSTed XML document to disk. ... used [fcopy], which didn't work. ...
    (comp.lang.tcl)
  • Re: macADT and .dsk images over 140k
    ... Use a hex editor that loads the entire ... the download image has trash added beginning half way through the last sector of the disk, ... of the disk, and it has a shortened -properly formatted, however- hack directory. ...
    (comp.sys.apple2)
  • Re: XP-32 cant read dynamic disk set after Win7 install
    ... would be the 1MB database used by the dynamic disk. ... There is also the 64KB or smaller metadata used by a RAID ... controller, to keep track of disks in an array. ... resulting small file with a hex editor. ...
    (microsoft.public.windowsxp.general)
  • Re: Using Linux to Recover bad NTFS drive.
    ... > holders) are the only ones in a position to make a checker ... I would not touch the file system or the disk until at least ... chkdsk over it is not likely to help and is more likely to ... I do not advocate a hex editor. ...
    (comp.os.linux.misc)