[comp.sys.mac.programmer] Screen vs. Printing

jwright@cs.iastate.edu (Jim Wright) (02/01/90)

I'm afraid I have a bug in a program in a printing routine.  I want to
generate information a few pages at a time, and have (modal) dialogs
come up between page groups.  This is all to be sent to the printer as
a single print job.  How should I manage the screen port and the print
port?  I put in SetPort() calls as I switched around, and all seemed
to work well.  Then I added an abort option, and very occasionally the
program hangs when quitting.  It still operates OK.  Of course it never
bombs while in the debugger.  How should I handle this, or can I just
ignore it all?  Any references to read up on this?  IM and TN have been
little help.

--
Jim Wright
jwright@cs.iastate.edu

odawa@well.UUCP (Michael Odawa) (02/04/90)

In article <456@dino.cs.iastate.edu> jwright@cs.iastate.edu (Jim Wright) writes:
> I'm afraid I have a bug in a program in a printing routine...I want to
> generate information a few pages at a time, and have (modal) dialogs come 
> up between page groups...I put in SetPort() calls as I switched around, and
> all seemed to work well.  Then I added an abort option, and very occasionally 
> the program hangs when quitting.

Problems from aborting print jobs are almost always caused by unbalanced
prOpenDoc()--prCloseDoc(), prOpenPage()--prClosePage() pairs.  Whenever you
call the first of a pair, you MUST call the last, or you're SOL.

From the sound of the problem, you might check to make sure the Abort
procedure closed up all your open--close pairs properly.  Also, the PrintMgr
probably expects to be set to the printing port when you call these, so make
sure that your SetPort()s always put you back into the pPrPort for aborting.

Good luck.

Michael Odawa
Simple Software
odawa@well.sf.ca.us