home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 13 / CDA13.ISO / cdactual / demobin / share / program / Pascal / ANSIDRVR.ZIP / DEMOBOTH.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-05-03  |  4.7 KB  |  251 lines

  1. {
  2. Turbo Pascal ANSI Drivers
  3. Version 1.12
  4. Copyright (c) 1990 by Not So Serious Software
  5.  
  6. Original concept by Ian Silver
  7. Design and implementation by Kevin Dean
  8.  
  9. Kevin Dean
  10. Fairview Mall P.O. Box 55074
  11. 1800 Sheppard Avenue East
  12. Willowdale, Ontario
  13. CANADA    M2J 5B9
  14. CompuServe ID: 76336,3114
  15. }
  16.  
  17.  
  18. { This program demonstrates simple text I/O using the CONCOMIO unit }
  19. program DemoANSIBoth;
  20.  
  21.  
  22. uses
  23.   ANSI, CONCOMIO;
  24.  
  25.  
  26. var
  27.   Result : integer;
  28.   Name : string[20];
  29.   BoxColor, DataColor, BkgndColor : byte;
  30.  
  31.  
  32. {***}
  33. procedure UpdateCursorPos;
  34.  
  35. var
  36.   CurX, CurY, OldAttr : byte;
  37.  
  38. begin
  39. CurX := WhereX;
  40. CurY := WhereY;
  41. OldAttr := TextAttr;
  42.  
  43. TextAttr := DataColor;
  44. GotoXY(50, 13);
  45. Write('(', CurX : 2, ',', CurY : 2, ')');
  46.  
  47. TextAttr := OldAttr;
  48. GotoXY(CurX, CurY)
  49. end;
  50.  
  51.  
  52. {***}
  53. procedure DrawBox;
  54.  
  55. var
  56.   I : byte;
  57.  
  58. begin
  59. TextAttr := BoxColor;
  60.  
  61. GotoXY(23, 9);
  62. UpdateCursorPos;
  63. Write('╔');
  64.  
  65. for I := 24 to 57 do
  66.   begin
  67.   UpdateCursorPos;
  68.   Write('═')
  69.   end;
  70.  
  71. UpdateCursorPos;
  72. Write('╗');
  73.  
  74. for I := 10 to 15 do
  75.   begin
  76.   GotoXY(58, I);
  77.   UpdateCursorPos;
  78.   Write('║')
  79.   end;
  80.  
  81. GotoXY(58, 16);
  82. UpdateCursorPos;
  83. Write('╝');
  84.  
  85. for I := 57 downto 24 do
  86.   begin
  87.   GotoXY(I, 16);
  88.   UpdateCursorPos;
  89.   Write('═')
  90.   end;
  91.  
  92. GotoXY(23, 16);
  93. UpdateCursorPos;
  94. Write('╚');
  95.  
  96. for I := 15 downto 10 do
  97.   begin
  98.   GotoXY(23, I);
  99.   UpdateCursorPos;
  100.   Write('║')
  101.   end
  102. end;
  103.  
  104.  
  105. {***}
  106. procedure RunDemo;
  107.  
  108. begin
  109. Randomize;
  110.  
  111. repeat
  112.   BoxColor := Random(256);
  113.  
  114.   DrawBox;
  115.  
  116.   DataColor := Random(256);
  117.   BkgndColor := Random(256);
  118.  
  119.   TextAttr := BkgndColor;
  120.   GotoXY(24, 10);
  121.   UpdateCursorPos;
  122.   Write(' Your name:                       ');
  123.   UpdateCursorPos;
  124.  
  125.   TextAttr := DataColor;
  126.   GotoXY(36, 10);
  127.   UpdateCursorPos;
  128.   Write(Name);
  129.   UpdateCursorPos;
  130.  
  131.   TextAttr := BkgndColor;
  132.   GotoXY(24, 11);
  133.   UpdateCursorPos;
  134.   Write(' Box color:       Data color:     ');
  135.   UpdateCursorPos;
  136.  
  137.   TextAttr := DataColor;
  138.   GotoXY(36, 11);
  139.   UpdateCursorPos;
  140.   Write(BoxColor : 3);
  141.   UpdateCursorPos;
  142.   GotoXY(54, 11);
  143.   UpdateCursorPos;
  144.   Write(DataColor : 3);
  145.   UpdateCursorPos;
  146.  
  147.   TextAttr := BkgndColor;
  148.   GotoXY(24, 12);
  149.   UpdateCursorPos;
  150.   Write(' Background color:                ');
  151.   UpdateCursorPos;
  152.  
  153.   TextAttr := DataColor;
  154.   GotoXY(43, 12);
  155.   UpdateCursorPos;
  156.   Write(BkgndColor : 3);
  157.   UpdateCursorPos;
  158.  
  159.   TextAttr := BkgndColor;
  160.   GotoXY(24, 13);
  161.   UpdateCursorPos;
  162.   Write(' Current cursor position:         ');
  163.   UpdateCursorPos;
  164.  
  165.   TextAttr := BkgndColor;
  166.   GotoXY(24, 14);
  167.   UpdateCursorPos;
  168.   Write('                                  ');
  169.   UpdateCursorPos;
  170.  
  171.   TextAttr := BkgndColor;
  172.   GotoXY(24, 15);
  173.   UpdateCursorPos;
  174.   Write(' Press any key to end demo.       ');
  175.   UpdateCursorPos;
  176. until KeyPressed
  177. end;
  178.  
  179.  
  180. {$F+}
  181.  
  182. {***}
  183. { Modem error handler - MUST BE COMPILED AS A FAR PROCEDURE }
  184. procedure ModemError(var Error : word);
  185.  
  186. begin
  187. { Disable serial port by sending output to console only }
  188. ActiveOutput := ConsoleActive;
  189.  
  190. if Error and ReceiveOverrun <> 0 then
  191.   WriteLn('Error : Receive overrun');
  192.  
  193. if Error and TransmitOverrun <> 0 then
  194.   WriteLn('Error : Transmit overrun');
  195.  
  196. if Error and ParityError <> 0 then
  197.   WriteLn('Error : Parity error');
  198.  
  199. if Error and FramingError <> 0 then
  200.   WriteLn('Error : Framing error');
  201.  
  202. if Error and BreakDetect <> 0 then
  203.   WriteLn('Error : Break detect');
  204.  
  205. if Error and CommTimeOut <> 0 then
  206.   WriteLn('Error : Modem time out');
  207.  
  208. if Error and NoCarrier <> 0 then
  209.   WriteLn('Error : No carrier');
  210.  
  211. if Error and CtrlBreak <> 0 then
  212.   WriteLn('Error : Ctrl-Break');
  213.  
  214. if Error and NotOnline <> 0 then
  215.   WriteLn('Error : Not on-line');
  216.  
  217. Disconnect;
  218. ReleaseCOM;
  219. halt(1)
  220. end;
  221.  
  222. {$F-}
  223.  
  224.  
  225. {***}
  226. begin
  227. { IF A BREAK COMES FROM THE KEYBOARD, AN INT 23h IS GENERATED AND THE
  228.   COMMUNICATIONS INTERRUPTS MAY NOT BE UNLOADED, LEAVING YOUR COMPUTER IN AN
  229.   UNKNOWN STATE.  SET CheckBreak TO FALSE TO PREVENT THIS. }
  230. CheckBreak := false;
  231.  
  232. Result := InitCOM(1, 1200, 8, 'N', 1, NoInit, SyncTransmit, @ModemError);
  233.  
  234. { It is very important to make an explicit call to either GotoXY or ClrScr at }
  235. { the start of your program.  If you do not do so, the internal cursor        }
  236. { position management will be unpredictable.                                  }
  237. ClrScr;
  238.  
  239. WriteLn('This program demonstrates simple I/O using the ANSI, ANSI console,');
  240. WriteLn('and ANSI communications units.  Among the features demonstrated are');
  241. WriteLn('screen control, cursor control, text attribute control, input and');
  242. WriteLn('output, and the delay counter.');
  243. WriteLn;
  244. Write('What is your name (maximum 20 characters)? ');
  245. ReadLn(Name);
  246.  
  247. RunDemo;
  248.  
  249. { ALWAYS MAKE SURE THAT YOU RELEASE THE COMMUNICATIONS PORT BEFORE EXITING }
  250. ReleaseCOM
  251. end.