Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ames!think!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!uunet!seismo!sundc!newstop!sun!imagen!qmsseq!pipkins From: pipkins@qmsseq.imagen.com (Jeff Pipkins) Newsgroups: comp.sys.ibm.pc Subject: Re: HELP! Using DOS print Message-ID: <51@qmsseq.imagen.com> Date: 30 Nov 89 16:38:29 GMT References: <6534@brspyr1.BRS.Com> Reply-To: pipkins@qmsseq.UUCP (Jeff Pipkins) Distribution: usa Organization: QMS Inc., Mobile, Alabama Lines: 44 In article <6534@brspyr1.BRS.Com> jillj@brspyr1.BRS.Com (Jill Jacomine) writes: >I am trying to execute the DOS (version 3.1) print command from within >an executable (compliled using MSC 5.1). The command I am using is: > > spawnvp(P_WAIT,"print.com",args); > >The value of args is "print /D:prn filename". Now, this works well >enough to print the file out, the problem seems to be setting the device >within the program eats up about 200k of memory, and never lets it go. >(I tried setting the device before executing the program, and it seems >to work fine, therefore I am relativly sure the problem is with the >/D:prn option). A chkdsk before running the program shows 655360 bytes >total memory and 594256 bytes free, after execution it is 426720 bytes >total memory and 356616 bytes free. PRINT is a "TSR" program. The first time you run it, it installs itself into your precious memory. If your program loads it, realize that chances are very high that it will be loaded RIGHT AFTER your program in memory. After your program terminates, PRINT STAYS THERE -- and you have irrecoverable memory fragmentation. DOS usually loads new programs in the first hole that it will fit in, so a program may use that hole, but if it tries to use the DOS SETBLOCK function to increase its size, it will most likely fail. This problem occurs any time a nonresident program loads a resident program. I have only thought of two possible work-arounds, and I don't like either of them: 1) Reserve enough memory below your program so that you can load the TSR there. 2) Modify DOSs memory control blocks to allocate just the right size block high in memory; then use the overlay option of DOSs EXEC function to load the program into that memory. I would be very interested in hearing other possible solutions from anyone else! /*=======================================================================*\ Jeff Pipkins: pipkins@imagen.com My views are not necessarily shared by my employer or the IRS. That explains a lot about my paycheck. "Why is it that unpitted dates have pits and pitted dates do not?" \*=======================================================================*/