Re: OK, just this once :)

Posted by webmaster Guido on May 02, 2003

In Reply to: Yessss I have it done......except for one little thing...please help :) posted by Jason on April 30, 2003

: I think I have it right is this it?

: program textfile;

: {$APPTYPE CONSOLE}

: uses
: SysUtils;

: const
: FileName = 'numbers.txt';
: var
: f : textfile;
: i : integer;
: begin
: assignfile (f, filename);
: rewrite (f);
: for i := (12, 14, 2, 78, 3) do
: writeln (f)
: closefile (f);
: end.

: I think I am right on the money with this one.......but I can't get it to write the numbers (12, 14, 2, 78, 3) to the textfile......... can you help me with this please?

As I wrote earlier on, DelphiLand is about GUI Windows applications, not about console applications. But for this once, and since I had a bit of spare time, and it's quite short, let's make an exception :)

program TxtFile;


{$APPTYPE CONSOLE}

uses
  SysUtils;
		
const
  FileName = 'numbers.txt';
  Numbers: array [1..5] of integer = (12, 14, 2, 78, 3);

var
  F: textfile;
  i: integer;
begin
  Assignfile(F, Filename);
  Rewrite(F);
  for i := 1 to 5 do
    WriteLn(F, Numbers[i]);
  CloseFile (F);
end. 

 


[ DelphiLand Discussion Forum ]
Compiling Console Applications
Learn Pascal with simple Delphi Console Applications