Board index » delphi » ****Need Help in Turbo Pascal 7.0****

****Need Help in Turbo Pascal 7.0****

Please tell me how to write to a text file using TP 7.0.  The sooner
you could respond the better...thanks.
 

Re:****Need Help in Turbo Pascal 7.0****


VAR
   F   : Text;

BEGIN
   Assign (F, 'C:\TEST');
   Rewrite(F);
   Write(F, 'Hello World');
   Close(F);
END;

Quote
>Please tell me how to write to a text file using TP 7.0.  The sooner
>you could respond the better...thanks.

Re:****Need Help in Turbo Pascal 7.0****


Quote
rs...@tcd.net (Pip Sanders) wrote:
>Please tell me how to write to a text file using TP 7.0.  The sooner
>you could respond the better...thanks.

Look at the tutorial, listed at the URL below.

Glenn Grotzinger
mailto:ggr...@2sprint.net
MOD and S3M user extraordinaire.
Writer of TP tutorial.  All released parts findable at:
ftp://garbo.uwasa.fi/pc/turbopas/tptutr0e.zip

Re:****Need Help in Turbo Pascal 7.0****


          Here is a quick example:

          PROGRAM TEXT_WRITE (OUTPUT,INPUT);

          USES
            Crt,Dos;

          VAR
            UserStr: String;
            F: Text;

          BEGIN {MAIN}
            ClrScr;
            Write('Enter in text to write to file:  ');
            ReadLn(UserStr);
            Assign(F, 'DELME.FIL');
            {$I-}
            Reset(F);
            {$I+}
            If IOResult <> 0 then ReWrite(F)
                             else Append(F);
            Write(F,UserStr);
          END.  {MAIN}

          That will write any user string to a file and check for if
          you are writing over a already existing file.  You might
          need to reserve memory later in your program if you are
          writing large arrays or large records to a file.  Hope this
          helps...

          ------------------------------------------------------------
          -  Roger Eckrode                  "Think Deep,             -
          -  Spangdahlem Germany             Listen Sharp,           -
          -                                  Guard Your Tongue"      -
          ------------------------------------------------------------

Re:****Need Help in Turbo Pascal 7.0****


In article <2157cc$1305....@genesis.ilinkgn.net>, rs...@tcd.net (Pip Sanders) says:

Quote

>Please tell me how to write to a text file using TP 7.0.  The sooner
>you could respond the better...thanks.

Nothing could be simpler.

var T : Text;

begin
        Assign(T,'TEST.TXT');
        Rewrite(T);
        Writeln(T,'This is a string to write to the text file');
        Close(T);
end.

Re:****Need Help in Turbo Pascal 7.0****


Quote
rs...@tcd.net (Pip Sanders) wrote:
>Please tell me how to write to a text file using TP 7.0.  The sooner
>you could respond the better...thanks.

If you're talking about writing a program in Pascal that will
creat/write to  a text file, then here's what you do.

Var Filename : Text;
        filevar       : string;

begin
assign(filename,'myfile.txt');
rewrite(filename);
Writeln(filename,'my text goes in here');
close(filename);
end.

Other Threads