[comp.sys.mac.programmer] Proper use of low-level printer driver calls ?

pascal@CAM.ORG (Pascal Gosselin) (02/05/91)

Sorry if some of you have already read this, I am reposting a request since
my last query did not generate any response whatsoever.

Problem: My application doesn't release a networked ImageWriter after use.

Code is MPW Pascal 3.1, looks something like this...

Unit PrintStuff;

Uses
	MemTypes,QuickDraw,Sane,Printing,Ctree .... etc....;

Procedure PrintSomeStuff;

Begin
     PrDrvrOpen;
     PrCtlCall(iPrDevCtl,lPrReset,0,0);
     PrCtlCall(iPrIOCTL,  ... various ascii streams .... ,buflen,0);
     .. . lots more of those calls ...
     PrCtlCall(iPrDevCtl, ... line feeds, page ends, etc....   );
     PrDrvrClose;
End;



The application is able to print fine, but control of the printer is no
longer possible after the printing is finished.  That is, the appletalk
connection does not close after the PrDrvrClose routine is called.

In fact, the PrCtlCall(iPrDevCtl,lPrReset,0,0); will not work if
the user tries to print twice in a row.  It will however work if the
user prints AFTER the printer has timed-out the connection (form feed
is issued automatically by the ImageWriter).

Also, after quitting the application, the system will often crash within
another application (or MPW shell....) within seconds or minutes.  I
therefore suspect that I am doing something terribly wrong that is leaving
code where it shouldn't be !!!

What am I doing wrong?   Thanks!




-- 
+----------------------------------------------------------------------------+
| Pascal Gosselin          | Internet: P.Gosselin@CAM.ORG Applelink: CDA0585 |
| Gest-Mac Inc. Apple VAR  |   Voice (514) 767-4444   Fax (514) 767-7337     |
+----------------------------------------------------------------------------+