Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
FILES Posted by johnpilula on 12 Mar 2003 at 4:23 AM
I NEED HELP ON THE SOURCE CODE ON HOW TO STORE A FILE AND RETRIEVED WHEN CALLED UPON
THANX
Report
Re: FILES Posted by zibadian on 12 Mar 2003 at 5:11 AM
: I NEED HELP ON THE SOURCE CODE ON HOW TO STORE A FILE AND RETRIEVED WHEN CALLED UPON
: THANX
:
That is a very general question, but here are two sources, which will store and then display any number f lines entered by the user. For more specialized file-IO, you need to be more specific in your question.
var
  f: text;
  s: string;
begin
  Assign(f,'somefile.txt');
  Rewrite(f);
  repeat
    write('enter a text:'); readln(s);
    writeln(f, s);
    write('Want to stop ?');
  until Upcase(ReadKey)='Y';
  Close(f);
end.


var
  f: text;
  s: string;
begin
  Assign(f,'somefile.txt');
  Reset(f);
  while not eof(f) do begin
    readln(f, s);
    writeln(s);
  end;
  Close(f);
end.




 

Recent Jobs