home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Programming Tools / Turbo Pascal / Utilities / PRINT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-06-16  |  2.4 KB  |  111 lines  |  [TEXT/ttxt]

  1. Program PrintDemo;
  2. {This is a simple example of how to use the Printing Manager. It is
  3.  currently set up for Turbo Pascal, but can easily be made to work
  4.  with LS Pascal, TML Pascal, or MPW Pascal with simple changes in
  5.  compiler directives.} 
  6. {$U-}
  7.  
  8. USES Memtypes,QuickDraw,OSIntf,ToolIntf,PackIntf,MacPrint;
  9.  
  10. VAR
  11.   PrintingPort:GrafPtr;
  12.   PrintRecHandle:THPrint;
  13.   PrintRecPtr:TPPrint;
  14.   PrintRec:TPrint;
  15.   PrintPort:TPPrPort;
  16.   PRect:rect;
  17.   PrintStatusRec:TPrStatus;
  18.  
  19.  
  20. PROCEDURE Debug (Message : str255; n : LongInt);
  21.   {Writes debugging information in the Menu Bar.}
  22. CONST
  23.   Top = 0;
  24.   Left = 375;
  25.   Bottom = 18;
  26.   Right = 500;
  27. VAR
  28.   d : rect;
  29.   ticks : LongInt;
  30.   tPort,ScreenPort : GrafPtr;
  31.   str:string;
  32. BEGIN
  33.   GetPort(tPort);
  34.   GetWMgrPort(ScreenPort);
  35.   SetPort(ScreenPort);
  36.   SetRect(d, Left, Top, Right, Bottom);
  37.   EraseRect(d);
  38.   MoveTo(Left, Top + 15);
  39.   DrawString(Message);
  40.   IF n <> -1 THEN BEGIN
  41.     DrawString(' ');
  42.     NumToString(n,str);
  43.     DrawString(str);
  44.   END;
  45.   delay(30, ticks);
  46.   SetPort(tPort);
  47. END;
  48.  
  49.  
  50. PROCEDURE init;
  51.   {Not required when using LS Pascal}
  52. BEGIN
  53.   InitGraf(@ThePort);
  54.   InitFonts;
  55.   InitWindows;
  56.   InitMenus;
  57.   TEInit;
  58.   InitCursor;
  59. END;
  60.  
  61. PROCEDURE Draw;
  62.   {Draws a triangle. Replace with your own drawing routine.}
  63. BEGIN
  64.   MoveTo(100,100);
  65.   LineTo(200,100);
  66.   LineTo(150,200);
  67.   LineTo(100,100);
  68. END;
  69.  
  70. PROCEDURE ErrCheck;
  71. VAR
  72.   err:integer;
  73.   ticks:LongInt;
  74. BEGIN
  75.   err:=PrError;
  76.   IF err<0 THEN BEGIN 
  77.     SysBeep(1);
  78.     debug('Print Error =',err);
  79.     delay(300,ticks);
  80.   END;
  81. END;
  82.  
  83. PROCEDURE Print;
  84. VAR
  85.   err:Integer;
  86.   result:boolean;
  87. BEGIN
  88.   PrOpen; ErrCheck; debug('PrOpen',-1);
  89.   PrintRecPtr:=@PrintRec;
  90.   PrintRecHandle:=@PrintRecPtr;
  91.   PrintDefault(PrintRecHandle); debug('PrintDefault',-1);
  92.   prect:=PrintRec.prInfo.rPage;
  93.   result:=PrJobDialog(PrintRecHandle); debug('PrJobDialog',-1);
  94.   IF result THEN BEGIN
  95.     PrintPort:=PrOpenDoc(PrintRecHandle,NIL,NIL); ErrCheck; debug('PrOpenDoc',-1);
  96.     PrOpenPage(PrintPort,NIL); ErrCheck; debug('PrOpenPage',-1);
  97.     Draw; debug('Drawing',-1);
  98.     PrClosePage(PrintPort); ErrCheck; debug('PrClosePage',-1);
  99.     PrCloseDoc(PrintPort); ErrCheck; debug('PrCloseDoc',-1);
  100.     IF PrintRecHandle^^.prJob.bJDocLoop=bSpoolLoop
  101.       THEN PrPicFile(PrintRecHandle,NIL,NIL,NIL,PrintStatusRec);
  102.   END;
  103.   PrClose; debug('PrClose',-1);
  104. END;
  105.  
  106. BEGIN
  107.   Init;
  108.   Print;
  109. END.
  110.  
  111.