home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / ctkit11.zip / CTU.PAS < prev    next >
Pascal/Delphi Source File  |  1991-12-14  |  2KB  |  118 lines

  1. Unit Ctu;
  2.  
  3. interface
  4.  
  5. USES
  6.   Dos, Async2;
  7.  
  8. CONST
  9.   Version = '1.1';
  10.   Rev = '';      {revision code, for compatibility checking}
  11.   Esc = #27;
  12.   EndChar = #255;
  13.   OK = #1;
  14.   NOTOK = #2;
  15.   NulCh = #0;
  16.   AltX = Chr(45);
  17.   AltC = Chr(46);
  18.   AltF = Chr(33);
  19.   Alpha = ['A'..'Z','0'..'9','a'..'z','.',':'];
  20.   InitCode = Esc+#236;
  21.  
  22. type
  23.    cnftype = record
  24.       ctdir: string;
  25.       Dport, dbaud: word;
  26.       quiet: boolean;
  27.       end;
  28.  
  29. var
  30.    cnf: cnftype;
  31.    Quiet: boolean;
  32.  
  33. Function Waitforchar: char;
  34. Function GetString: string;
  35. {
  36. Function ReadKey: char;
  37. Function KeyPressed: boolean;
  38. }
  39. Procedure Delay(time: word);
  40.  
  41. implementation
  42.  
  43. FUNCTION WaitForChar : CHAR;
  44.  
  45. VAR
  46.    t: WORD;
  47.  
  48. BEGIN
  49. t := 0;
  50. REPEAT
  51.    INC(t);
  52.    UNTIL (t>65500) OR Async_Buffer_Check;
  53. IF Async_Buffer_Check THEN
  54.    WaitForChar:=Async_Read
  55.    ELSE
  56.    WaitForChar:=#0;
  57. END;
  58.  
  59. Function GetString: string;
  60.  
  61. var ts: string;
  62.    ch: char;
  63.  
  64. begin
  65. ts := '';
  66. repeat
  67.    ch := WaitForChar;
  68.    if (ch <> #0) and (ch <> EndChar) then
  69.       ts := ts + ch;
  70.    until (ch = #0) or (ch = EndChar);
  71. GetString := ts;
  72. end;
  73. {
  74. Function ReadKey: char;
  75.  
  76. var
  77.    Regs: registers;
  78.    ch, s: char;
  79.  
  80. begin
  81. Regs.ah := $08;
  82. Intr ($21, Regs);
  83. Ch := Chr(Regs.al);
  84. readkey := ch;
  85. end;
  86.  
  87. Function KeyPressed: boolean;
  88.  
  89. var
  90.    ch: char;
  91.    regs: registers;
  92.  
  93. begin
  94. KeyPressed := false;
  95. Regs.AH := $0B;
  96. Intr($21,Regs);
  97. if Regs.AL = 255 then
  98.    KeyPressed := true;
  99. end;
  100. }
  101. Procedure Delay (Time: word);
  102.  
  103. var
  104.    h, m, s, s100, tot1, tot2: word;
  105.  
  106. begin
  107. Time := Time div 10;
  108. GetTime (h, m, s, s100);
  109. tot1 := s100+s*100+m*6000+h*36000;
  110. repeat
  111.    GetTime (h, m, s, s100);
  112.    tot2 := s100+s*100+m*6000+h*36000;
  113.    until tot2 - Time >= tot1;
  114. end;
  115.  
  116. begin
  117. Quiet := false;
  118. end.