Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
UNIT  UnInOut;  { UNINOUT.PAS  A Unix like basic input/output }
                { Borsuk  Pi 95/12/01  09:05  V001 }
 
INTERFACE
 
  USES  Crt;
 
  VAR   stdin, stdout, stderr: Text;
 
  PROCEDURE  UnOpen;
  PROCEDURE  UnClose;
  PROCEDURE  Wait;
  PROCEDURE  Wayt;
 
IMPLEMENTATION
 
  PROCEDURE  Wait;
  VAR  w: Char;
  BEGIN
    w := ReadKey;
    IF (w = #$1B)  THEN  Halt;
    IF (w = #$0D)  THEN  WriteLn( stderr );
  END;  { Wait }
 
  PROCEDURE  Wayt;
  VAR  w: Char;
  BEGIN
    Write( stderr, #15 ); { Velka hviezdica ako prompt }
    w := ReadKey;
    Write( stderr, #8#32#8 );
 
    IF (w = #$1B)  THEN  Halt;
    IF (w = #$0D)  THEN  WriteLn( stderr );
  END;  { Wayt }
 
  PROCEDURE  UnOpen;
  BEGIN
    Assign( stdin,  '' );  ReSet(   stdin  );
    Assign( stdout, '' );  ReWrite( stdout );
    AssignCrt( stderr  );  ReWrite( stderr );
  END;  { UnOpen }
 
  PROCEDURE  UnClose;
  BEGIN
    WriteLn( stdout );  Close( stdout );
    Close(   stdin  );  Close( stderr );
  END;  { UnClose }
 
  BEGIN { main() = UNINOUT.PAS }
    UnOpen;
  END.  { main() = UNINOUT.PAS }