Start New Discussion within our Software Development Community

Hi there DaniWeb community,

I have a problem with such a task: I need to create a programm that will open, give option to modify, and save modifications to other text file (with other name).

All I did so far is programm that can open a .txt file and read data from it.

Requesting some help :)

~tdmarko

program solution31;

uses crt,dos;

var name_and_path,s,temp:string;
    f,f2:text;
    c:char;
    counter:word;


begin (*main*)
   clrscr;
   counter:=0;
   writeln('give me the file''s name and its path: ');
   readln(name_and_path);
   assign(f2,'c:\bp\file\other.txt');
   rewrite(f2);
   assign(f,name_and_path);
   {$I-}
   reset(f);
   {$I+}
   if ioresult <> 0 then begin
      writeln('file reset error');
      readln;
      halt;
   end;
   writeln('the file''s contents: ');
   while not eof(f) do begin
         readln(f,s);
         inc(counter);
         writeln(counter,'. line:');
         writeln(s);
         repeat
               write('modify it? y = yes, n = no : ');
               readln(c);
               c:=upcase(c);
               case c of
                    'Y':begin
                             write('give me the new string: ');
                             readln(temp);
                             append(f2);
                             writeln(f2,temp);
                        end;
                    'N':begin
                             append(f2);
                             writeln(f2,s);
                        end;
               end;
         until (c = 'Y') or (c = 'N');
   end;
   close(f);
   close(f2);
   writeln('---------');
   writeln('now read the new file: ');
   readln;
   reset(f2);
   counter:=0;
   while not eof(f2) do begin
         readln(f2,s);
         inc(counter);
         writeln(counter,'. line: ');
         writeln(s);
   end;
   close(f2);
   repeat
   until keypressed;
end. (*main*)
(*created by FlamingClaw 2010.02.21.Hungary *)
This article has been dead for over six months. Start a new discussion instead.