ex38.pp 1.1 KB

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