ex38.pp 1.1 KB

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