home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 502b.lha / PCQ_v1.2 / PCQ_Examples / examples.LZH / Examples / ConsoleTest.p < prev    next >
Text File  |  1991-04-04  |  1KB  |  68 lines

  1. Program ConsoleTest;
  2.  
  3. {
  4.     This program demonstrates and tests the console IO routines.
  5. It uses the a small group of routines I wrote to make it a bit easier
  6. to port Turbo programs that do screen IO.
  7. }
  8.  
  9. {$I "Include:Exec/Ports.i"}
  10. {$I "Include:Intuition/Intuition.i" for window structures and functions }
  11. {$I "Include:Utils/CRT.i" for ReadKey, WriteString, AttachConsole, etc. }
  12.  
  13. var
  14.     w  : WindowPtr;
  15.  
  16. Function OpenTheWindow() : Boolean;
  17. var
  18.     nw : NewWindowPtr;
  19. begin
  20.     new(nw);
  21.     with nw^ do begin
  22.     LeftEdge := 20;
  23.     TopEdge := 50;
  24.     Width := 300;
  25.     Height := 100;
  26.  
  27.     DetailPen := -1;
  28.     BlockPen  := -1;
  29.     IDCMPFlags := 0;
  30.     Flags := WINDOWSIZING + WINDOWDRAG + WINDOWDEPTH +
  31.          SMART_REFRESH + ACTIVATE;
  32.     FirstGadget := nil;
  33.     CheckMark := nil;
  34.     Title := "Press q to Quit";
  35.     Screen := Nil;
  36.     BitMap := nil;
  37.     MinWidth := 50;
  38.     MaxWidth := -1;
  39.     MinHeight := 20;
  40.     MaxHeight := -1;
  41.     WType := WBENCHSCREEN_f;
  42.     end;
  43.  
  44.     w := OpenWindow(nw);
  45.     dispose(nw);
  46.     OpenTheWindow := w <> nil;
  47. end;
  48.  
  49. var
  50.     ConBlock : Address;
  51.     ch : Array [0..1] of Char;
  52. begin
  53.     if OpenTheWindow() then begin
  54.     ConBlock := AttachConsole(w);
  55.     if ConBlock <> Nil then begin
  56.         ch[1] := '\0'; { Just for ease of writing }
  57.         repeat
  58.         ch[0] := ReadKey(ConBlock);
  59.         WriteString(ConBlock, Adr(ch));
  60.         until ch[0] = 'q';
  61.         DetachConsole(ConBlock);
  62.     end else
  63.         Writeln('Could not open console device');
  64.     CloseWindow(w);
  65.    end else
  66.     writeln('Could not open the window');
  67. end.
  68.