ex38.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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,'/home/michael/fpk/rtl/linux/ex38a -son');
  12. if linuxerror<>0 then writeln ('AssignStream failed !');
  13. Writeln ('Speaking to son');
  14. For i:=1 to 10 do
  15. begin
  16. writeln (so,'Hello son !');
  17. if ioresult<>0 then writeln ('Can''t speak to son...');
  18. end;
  19. For i:=1 to 3 do writeln (so,'Hello chap !');
  20. close (so);
  21. while not eof(si) do
  22. begin
  23. readln (si,s);
  24. writeln ('Father: Son said : ',S);
  25. end;
  26. Writeln ('Stopped conversation');
  27. Close (Si);
  28. Writeln ('Put down phone');
  29. end
  30. Else
  31. begin
  32. Writeln ('This is the son ');
  33. While not eof (input) do
  34. begin
  35. readln (s);
  36. if pos ('Hello son !',S)<>0 then
  37. Writeln ('Hello Dad !')
  38. else
  39. writeln ('Who are you ?');
  40. end;
  41. // close (output);
  42. end
  43. end.