dredick@vax.bbn.com (The Druid) (05/19/88)
I am trying to print (to a LaserWriter) a simple couple of pages which contain graphics that I have generated with a program, But the program causes the machine to BOMB BIG TIME when I try to print. The program was originally written in Megamax C, now I am moving it to LSC. Some Notes: I generate graph data and put that in a file, then I retreive that data and plot the graphs in a printer port for x pages. I am using a standard Mac Plus with LSC 2.15. Here is the problem function: print(refnum) int refnum; { TPPrPort pprport; char line[255], head[255]; int lpp; /* lines per page */ int ltp; /* lines this page */ int bjdocloop; /* if = bspoolloop,then must print spool file */ int dx; /* width of page */ TPrStatus status; int page = 0; /* page number */ FontInfo finfo; int charheight; int i,j,y; int stop = FALSE; comic xc; if (!PrJobDialog(hprint)) return; bjdocloop = (*hprint)->prJob.bJDocLoop; pprport = PrOpenDoc(hprint, NIL, NIL); GetFontInfo(&finfo); charheight = finfo.ascent + finfo.leading + finfo.descent; lpp = ((*hprint)->prInfo.rPage.bottom - (*hprint)->prInfo.rPage.top)/charheight; ltp = 1; dx = ((*hprint)->prInfo.rPage.right - (*hprint)->prInfo.rPage.left); i = firstcard(refnum); while (!stop) { PrOpenPage(pprport, NIL); MoveTo(0, finfo.ascent); sprintf(head, "Graph 1.0"); TextFace(bold); CDrawString(head); sprintf(head, "Page: %d", ++page); MoveTo(dx-StringWidth(head), finfo.ascent); CDrawString(head); TextFace(0); for (j=0;j<6 && !stop;j++) { if (getgraph(refnum,i,&xc) != noErr) stop = TRUE; else { if ((j % 2) == 0) y = j*(100+0.75*charheight)+50; printgraph((j % 2) * (dx/2) + 55,y,xc); i = xc.flink; } } PrClosePage(pprport); } PrCloseDoc(pprport); if (bjdocloop == bSpoolLoop) PrPicFile(hprint, NIL, NIL, NIL, &status); SelectWindow(FrontWindow()); SetPort(FrontWindow()); } =============================================================================== = The Druid (dredick@bbn.com) = = "Did you ever feel that you were a typewriter, = = when everone else in the world was a wordprocessor" = ===============================================================================
kaufman@polya.STANFORD.EDU (Marc T. Kaufman) (05/20/88)
In article <24764@bbn.COM> dredick@vax.bbn.com (The Druid) writes:
.I am trying to print (to a LaserWriter) a simple couple of pages which
.contain graphics that I have generated with a program, But the
.program causes the machine to BOMB BIG TIME when I try to print.
.The program was originally written in Megamax C, now I am moving it
.to LSC.
.Here is the problem function:
.print(refnum)
.int refnum;
.{
. TPPrPort pprport;
. char line[255], head[255];
. int lpp; /* lines per page */
. int ltp; /* lines this page */
. int bjdocloop; /* if = bspoolloop,then must print spool file */
. int dx; /* width of page */
. TPrStatus status;
. int page = 0; /* page number */
. FontInfo finfo;
. int charheight;
. int i,j,y;
. int stop = FALSE;
. comic xc;
. if (!PrJobDialog(hprint)) return;
[...more]
I notice that hprint is not declared in this procedure. I hope it is a real
HANDLE, because the print routines tend to to HLock and HUnlock to things they
think are handles.
Marc Kaufman (kaufman@polya.stanford.edu)