~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to fpcdocs/unixex/ex38.pp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Program Example38;
 
2
 
 
3
{ Program to demonstrate the AssignStream function. }
 
4
 
 
5
Uses BaseUnix,Unix;
 
6
 
 
7
Var Si,So : Text;
 
8
    S : String;
 
9
    i : longint;
 
10
 
 
11
begin
 
12
  if not (paramstr(1)='-son') then
 
13
    begin
 
14
    Writeln ('Calling son');
 
15
    Assignstream (Si,So,'./ex38 -son');
 
16
    if fpgeterrno<>0 then
 
17
      begin
 
18
      writeln ('AssignStream failed !');
 
19
      halt(1);
 
20
      end;
 
21
    Writeln ('Speaking to son');
 
22
    For i:=1 to 10 do
 
23
      begin
 
24
      writeln (so,'Hello son !');
 
25
      if ioresult<>0 then writeln ('Can''t speak to son...');
 
26
      end;
 
27
    For i:=1 to 3 do writeln (so,'Hello chap !');
 
28
    close (so);
 
29
    while not eof(si) do
 
30
      begin
 
31
      readln (si,s);
 
32
      writeln ('Father: Son said : ',S);
 
33
      end;
 
34
    Writeln ('Stopped conversation');
 
35
    Close (Si);
 
36
    Writeln ('Put down phone');
 
37
    end
 
38
  Else
 
39
    begin
 
40
    Writeln ('This is the son ');
 
41
    While not eof (input) do
 
42
      begin
 
43
      readln (s);
 
44
      if pos ('Hello son !',S)<>0 then
 
45
         Writeln ('Hello Dad !')
 
46
      else
 
47
         writeln ('Who are you ?');
 
48
      end;
 
49
    close (output);
 
50
    end
 
51
end.