On Sun, 1 Aug 2004 [EMAIL PROTECTED] wrote:

> Ok, guys.  it's only been like 15 years since I have written any pascal code.
>  Can someone please help me with syntax for opening a file so that I can read
> variable length lines of text from it, then output to another file. Running
> in DOS on an x86 machine.  Thank you.

Here you are. Standard textbook examples. Also available in the manual.

Michael.

procedure ReadFile(FN : String);

Var
  F : Text;
  S : String;

begin
  Assign(F,FN);
  Reset(F);
  While not EOF(F) do
    begin
    ReadLn(F,S);
    { Do something with S. }
    end;
  Close(F);
end;

procedure WriteFile(FN : String);

Var
  F : Text;
  I : Integer;
  S : String;

begin
  Assign(F,FN);
  Rewrite(F);
  For I:=0 to 100 do
    Writeln(F,'Writing string ',I);
  Close(F);
end;


_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to