Quantcast
Channel: 'Data Storage and Reproduction Cont.' Thread RSS Feed
Viewing all articles
Browse latest Browse all 8

Re: Data Storage and Reproduction Cont.

$
0
0
: I still dont see how
:
:  Filename := 'somefile.txt';
:   Assign(f, Filename);
: 

: will let me assign the generated date and time as the filename.
: If I defined (useing ':=') "Filename" as 'somefile.txt' this makes Filename no less of a "variable" (ie something that changes) than If I simply went along and used the
:
 Assign(f, 'somefile.txt') 
version.
:
: If I code
:
: Assign(F, Filename) {Where Filename is the generated date and time}
: Append(F)
: 

:
: The compiler says 'Error 2: File not Found"

You're right, but since the file is non-existant, that's where you get your error. The file HAS to exist to use Append();
This is a safer way that should always be used:
Assign(F,FileName);
{$I-}                  { Return Error Code instead of Halting program }
Append(F);
IF IOResult <> 0 Then  { If there was an error, like File Not found...}
   Rewrite(F);         { ...then create the file.                     }
{$I+}                  { I like to do this, but you can just compile  }
                       { whole program in the $I- state.              }


Phat Nat


Viewing all articles
Browse latest Browse all 8

Trending Articles