Hi fellows ...
I'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD.
Thanks in advance.
Neilson

Mailing lists / fpc-pascal / 2001-03
14 messages · 8 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi fellows ...
I'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD.
Thanks in advance.
Neilson
Neilson Henriques wroteI'm a newbie using FPC so I asking for how can I read stdin. My FPC is 1.0.4 running under FreeBSD.
var
stdin: text;
s: string;
begin
assign(stdin,'');
reset(stdin);
readln(stdin,s);
end.You can normally even simply use
var
s: string;
begin
readln(s);
end.The default input is stdin.
Jnas
Hi fellows ... I'm a newbie using FPC so I asking for how can I read stdin. My FPC is…
Perhaps I misunderstand the question,
but couldn't you use Readln, read, or keypressed/readkey? (if you use the CRT unit). Under most systems (and Pascals), stdin is assigned to be the default for readln (and likewise stdout for writeln). So, to read in a string from the standard input, you could use:
var
st:string;
begin
readln(st);
end;If you were looking for a charicter by charicter basis, you could use readkey. If you need more examples, let me know.
thanks,
noah silva
Noah silva wroteIf you were looking for a charicter by charicter basis, you could use readkey. If you need more examples, let me know.
Note that readkey doesn't work with stdin, but with the keyboard (even if stdin is redirected from a file or so).
Jonas
Perhaps I misunderstand the question, but couldn't you use Readln, read, or…
It is possible to use readkey under FreeBSD, but from the ncrt unit, not the CRT unit. The Linux Crt unit is very Linux specific, and was not portable to FreeBSD.
so how would one do say echo "hello world" | freepascal-program
Is that possible on FreeBSD ?
Si.
Si. wroteso how would one do say echo "hello world" | freepascal-program
program HelloWorld;
begin
writeln('Hello World!');
end.Jonas
I think you miss the point of what i want.
I was to be able to read from stdin. i.e. i want to be able to pipe '|' data into a program. That was purely an example. I would assume this is quite a trvial thing to do but as of yet i havent been able to figure it out.
Thanks,
Si.
What about a simple
program readsomething;
Var
S : String;
begin
While not EOF do
begin
readln(s);
writeln('Got : ',S);
end;
end.I would think this is basic pascal syntax.
Michael.
so how would one do say echo "hello world" | freepascal-program Is that possible on…
so how would one do say echo "hello world" | freepascal-program Is that possible on FreeBSD ?
Sure, no problem. The CGI's even function that way. E.g. :
var c : Char;
begin
While not EOF(input) DO
begin
read(c);
write(c);
end;
end.Oops, sorry it was my testing that have been echo "hello world" | ./freepascal-program. no wonder it didnt work, hehe.
Thanks for all your help guys, thats another util written. FreePascal is by the far the best language for doing unix sysadm type stuff :)
Then look at the code in the previous mail I sent.
Jonas
Oops, sorry it was my testing that have been echo "hello world" | ./freepascal-program. …
Hello,
I'm writing a program in fpc for Linux, using a connection to mysql, but I need the "libmysqlclient" of Red Hat Linux 5.0 [Hurricane]. Does anybody know where I find it, because others "libs" versions do not work on Red Hat 5.0
Thanks for help.
,o888b,`?88888 Anderson R. Livramento
,8888 888 ?888 REDES E CONECTIVIDADE - Pesquisa & Desenvolvimento 8888888P' 888 Digilab S.A - Solucoes digitais
888P' 888 Florianopolis - SC - Brasil
`88 O d888 http://www.digilab.com.br
`?._ _.o888888888888888888888888888888888888888888888888888888888 "Onde quer que vc esteja, vc sempre estara la."
It's very simple to compile MySQL your self after downloading the source. You don't
have to give any options. Simply run configure and make.
Johan