Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-11

HOW TO, PROBLEM read stdin (linux) ??

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

TOUZEAU DAVID

Dear

What is the best way to read into a memory datas from this command.

"/bin/myprogram </home/tests/file.txt "

my test program read only the first line from stdline. What i miss ???

program myprogram;
{$mode objfpc}{$H+}
uses
  Classes, SysUtils;
var
  st: text;
  s: string;
begin
  assign(st,'');
  reset(st);
  readln(st,s);
  writeln(s)
end.
David Touzeau -------------------------- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console (http://www.artica.fr) icq:160018849
Wanderlan Santos dos Anjos
to TOUZEAU DAVID
program yourprogram;
{$mode objfpc}{$H+}
uses
 Classes, SysUtils;
var
 st: text;
 s: string;
begin
 assign(st,'');
 reset(st);
 while not eof(st) do begin // <<<<<<<<--- iterate while not en of file
   readln(st,s); //<<< read only a line
   writeln(s);
 end;
 close(st); // <<<<<---
end.
Att, Wanderlan Santos dos Anjos On Nov 24, 2007 8:15 AM, TOUZEAU DAVID wrote: > Dear > > What is the best way to read into a memory datas from this command. > > > "/bin/myprogram </home/tests/file.txt " > > > my test program read only the first line from stdline. > What i miss ??? > > > program myprogram; > > {$mode objfpc}{$H+} > > uses > Classes, SysUtils; > var > st: text; > s: string; > begin > assign(st,''); > reset(st); > readln(st,s); > > writeln(s) > > end. > > > > -- > David Touzeau -------------------------- Linux Ubuntu 7.04 feisty > FreePascal-Lazarus,perl,delphi,php artica for postfix management console > (http://www.artica.fr) icq:160018849 > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal >
TOUZEAU DAVID
to Wanderlan Santos dos Anjos

Great many thanks

Wanderlan Santos dos Anjos wrote 73 lines
program yourprogram; {$mode objfpc}{$H+} uses Classes, SysUtils; var st: text; s: string; begin assign(st,''); reset(st); while not eof(st) do begin // <<<<<<<<--- iterate while not en of file readln(st,s); //<<< read only a line writeln(s); end; close(st); // <<<<<--- end. -- Att, Wanderlan Santos dos Anjos On Nov 24, 2007 8:15 AM, TOUZEAU DAVID < > wrote: Dear What is the best way to read into a memory datas from this command. "/bin/myprogram </home/tests/file.txt " my test program read only the first line from stdline. What i miss ??? program myprogram; {$mode objfpc}{$H+} uses Classes, SysUtils; var st: text; s: string; begin assign(st,''); reset(st); readln(st,s); writeln(s) end. -- David Touzeau -------------------------- Linux Ubuntu 7.04 feisty FreePascal-Lazarus,perl,delphi,php artica for postfix management console ( http://www.artica.fr) icq:160018849 _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
* 01.41.39.04.42 * 06.20.56.74.33 * ICQ:160018849 * Skype:dtouzeau * Site technique destiné aux entreprises: http://entreprises.kaspersky.fr * Inscrivez-vous dès maintenant dans l'espace partenaires ! <http://partners.kaspersky.fr> (Retrouvez sur ces sites des faqs, tutoriaux, Forums et liens de téléchargement de la gamme Buiness Optimal) * *