Re: No errors for AssignFile ?

From: Skybuck Flying (nospam_at_hotmail.com)
Date: 11/12/04


Date: Fri, 12 Nov 2004 20:04:51 +0100


"Bruce Roberts" <ber@bounceitattcanada.xnet> wrote in message
news:pR5ld.150$rN5.189161@news20.bellglobal.com...
>
> "Skybuck Flying" <nospam@hotmail.com> wrote in message
> news:cn0ft1$c7a$1@news5.zwoll1.ov.home.nl...
>
> > If I run this code it simply returns and no errors happen ??
> >
> > AssignFile( F, '///\\$#^$#%^$#b23412ull***' );
>
> > Let me guess the error probably happens when I call
> >
> > writeln( F, 'blablabla' );
>
> You guessed wrong. The error happens on the Reset, Rewrite, or Append. The
> help is a little misleading on this issue. AssignFile does nothing more
than
> initialize the internal data space used by the VCL/Library. Reset,
Rewrite,
> and Append are the routines that actually communicate with the o/s to open
> the file.
>
> > Ok I just tried it:
> >
> > AssignFile( F, '///\\$#^$#%^$#b23412ull***' );
> > try
> > WriteLn( F, 'blabla' ); // i/o 103
> > except
> >
> > end;
> >
> > That's not so cool....
> >
> > What if I want to make sure that the file will exist ?
>
> Well most people would take the time to read the help. In it they will
find
> out that one must open a file before attempting i/o on it. They will also
> learn about $I-/+ and IOResult. And, if they spend just a little more time
> in the help they will probably find the FileExists function.
>
> If you spent as much time reading and understanding the Delphi help files
as
> you do litering this ng with junk posts, you just might learn something.
>
> > I can't use FileExists... because the file doesn't exist yet...
> >
> > I want to create it...
> >
> > Maybe do a reset ?
>
> Oh wow. Of course you want to use Reset. After all the help entry on the
> procedure starts with "Reset opens the existing external file . . ."
> obviously just what you want. I guess you've never tried to follow any see
> also links.
>
> > Write stuff/text to a textfile.
> >
> > But make sure the path/file is valid.
> >
> > If it is not valid given an error message ONCE
>
> var errorIssued : boolean = false;
>
> procedure WriteStuffToTextFile (theFilename : string; const stuff :
string);
>
> var f : textFile;
>
> begin

> if FileExists (theFilename)
> then begin
> AssignFile (f, theFilename);
> Append (f);
> Writeln (f, theStuff);
> CloseFile (f);
> end
> else begin

gosh so far it kinda ;) looks like my code :)

> if not errorIssued
> then begin

ohh here you *** up lol...

You should have used rewrite heheheheh to create the file.

> MessageBox ('Skybuck flunks again.');
> errorIssued := True;
> end
> else raise exception.Create ('Enough already. I already told you its
> wrong.');
> end;
> end;
>

Lol, Bruce flunks again lol

Bye,
  Skybuck.


Loading