[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Delphi Programming question

I have created a text file on F: the lan drive. Everynight I have to run a program which should rewrite this file. I do not have delete access on F: I can however erase the contents of the file, with which I am not having any luck. If I use reset procedure, the file is put in read-only mode. If I use append it is write only but I cannot loop until Bof to whitespace the previous records. I cannot use rewrite, erase or truncate as I get I/O errors on these procedures as I do not have rights to delete any file on F: How can I open my text file, loop through it to whitespace any records and then append the new data. This text file is being populated from some list boxes on my form.
Please help if you can.
Thank you
 Sam Kapoor
0
skapoor072897
Asked:
skapoor072897
1 Solution
 
jackb022197Commented:
AssignFile(f, 'F:\yourfile.txt');
FileMode := 1;      { Write only }
Reset(f);

Then loop through your file and append...


0
 
skapoor072897Author Commented:
I have tried this bit of code, but I keep running into the same problem. First I define f as a file type variable. This is the code
egin
  AssignFile(f, 'f:\cmailtest\phone.txt');
  FileMode := 1; { Write only }
  Reset(f);
  while not eof(f) do
   begin
    writeln('     ');
   end;
On the writeln('      ') line I get an I/O error 103.
I have changed the variable f: to a textfile type and tried the sam e code with writeln(f,'      '). Same I/O error 103. I have tried writing to C instead of F but get the same I/O error. Maybe something is not write with the writeln statement. How do I write out whitespaces to this text file.
Please help if you can.
Thanks,
           SKapoor
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now