Article View: comp.lang.pascal.borland
Article #683Re: Writing to text Files
From: Björn Teegen
Date: Sat, 05 Jun 1999 00:00
Date: Sat, 05 Jun 1999 00:00
39 lines
1795 bytes
1795 bytes
Hallo Ali!
> Could some one show me a quick little, simple source code how to write to
> text
> files, i've tried to write to a text file but i get an error: File not open
> for output (run time error, i think error no: 105). THis is how i try to
> write to text files:
> var
> f:text;
> c:char;
> begin
> read(c);
> assign(f,'fdsat.txt');
> reset(f);
> write(f,c);
> end.
Uses "reset" only for opening text files for input. These files must already
exist. If you want to wite to a file (as you tried), use "rewrite" to create a
new file, or "append" to extend an existing text file.
Furthermore, do not forget to close a file, otherwise it is not guaranteed that
buffers will be flushed and data be stored on disc.
Putting this altogether your code becomes:
var
f: text;
c: char;
begin
readln(c);
assign(f, 'fdsat.txt');
rewrite(f);
write(f, c);
close(f)
end.
Greetings,
Bj�rn
Technical Details
Message-ID:
<37591D2F.B3A6C558@gmx.de>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7jaola$r31$1@news5.svr.pol.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111659,863a3507bf12c2da X-Google-Attributes: gid111659,public X-Google-Thread: 110467,863a3507bf12c2da X-Google-Attributes: gid110467,public From: Björn Teegen <bjoern.teegen@gmx.de> Subject: Re: Writing to text Files Date: 1999/06/05 Message-ID: <37591D2F.B3A6C558@gmx.de> X-Deja-AN: 486005683 Content-Transfer-Encoding: 8bit References: <7jaola$r31$1@news5.svr.pol.co.uk> To: Ali <Bathman@gothom.freeserve.co.uk> X-Accept-Language: de X-Sender: 04821600224-0001@t-online.de Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@t-online.de X-Trace: news02.btx.dtag.de 928587416 8710 04821600224-0001 990605 12:56:56 Organization: T-Online Mime-Version: 1.0 Newsgroups: comp.lang.pascal.borland,fido.ger.pascal