TweetFollow Us on Twitter

Winter 91 - PRINT HINTS WITH LUKE & ZZ

PRINT HINTS WITH LUKE & ZZ

ZZ speaks

Once upon a time, in an engineering department far, far away, the great implementors (GIs) ran across a problem with their Frankensteinian monster. They had designed and built a powerful beast. A beast that had traveled great distances into unknown territories, and that had cut many new paths in the hot lead jungle. Many spoke of the creation, and it had become well known and respected in many lands and platforms. But the complexity that only the great implementors had dared to conceive was being challenged by the great hackers of the land. Many of them had conquered the secrets of the beast, and shared the knowledge of the great implementors. Soon, even mortal hackers would be able to control the beast. This would not do. . .

The GIs traveled far to find the infamous "field workers." They had already given the GIs the gift of dynamic, incomprehensible data structures, and the GIs were hopeful that they could provide something more. They could not. . .

At last, on their return from the field, they ran across a court jester. Like all good jesters, he was trying hard to find some fun. He tried to get the GIs to play a game with him. He tried Monopoly, Pictionary, even checkers, but the GIs were not interested (he did notice a little glimmer when he mentioned thermonuclear war, but not enough to be important). As a last resort, he finally said, "Pick a number." Suddenly, the great gods of arbitration came down on the GIs like a 5-ton weight. "Pick a number!" one of them shouted. "It's beautiful!" laughed another one. And soon they were off to the lab to implement their new discovery.

This folks, is the not-based-on-a-true-story story of the constant named iPfMaxPgs. This constant is part of the Printing Manager, and limits the number of pages that can be spooled (that is, written to disk) in one print job. In the old days, when even engineers at Apple were using floppy drives, the Print Shop came to the conclusion that there should be a limit on the number of pages you could print in a single job. If not, the user could easily use up all the disk space on the boot disk, which at the time, led to other, even more interesting problems. The decision to limit the number of pages was quickly followed by a decision to use the court jester's advice and "pick a number." The magic number is 128, and is referenced by the constant iPfMaxPgs.

So now, you are printing your favorite report, all 130 pages of it, and just to annoy your neighbors, you're printing to your ImageWriter II in Best mode. You've placed the printer next to the window in the bathroom where the acoustics are especially outgoing, and the window is open for the extra cooling effect (at least, that's what you told the neighbors). As the head rips across the bottom of page 128 like nails across the chalkboard, you are suddenly greeted with a Printing Manager error code. Sure, your neighbors are happy, but you still have two pages to go. You frantically dig for that suicide prevention number (that your neighbors have obviously borrowed), but decide instead that printing more than 128 pages in one job would be a great way to get new neighbors.

To print jobs longer than 128 pages, you simply treat them like multiple jobs, printing each set of 128 pages just like the first set. To make this even simpler, it would be nice if there was one line of code that told you when to close the current document and open the new one. Welcome to the MOD squad (or the % Club for you C dudes).

The MOD instruction is very useful for tracking sets of things, like the number of pages in a print job. Most people that have implemented a Macintosh printing loop (you can spot them by the gray hair and growing forehead) use some kind of page loop.

The following code fragments will show the flow of control using the MOD operator. The parameters of the Toolbox routines have been omitted for simplicity.

Before you knew enough words to type 128-page documents, you used to have a print loop that figured out how many pages you had to print and then printed them one at a time.

This works well for bothering neighbors, but you'll never get any For Sale signs with this technique. To print jobs larger than 128 pages, you need to call PrOpenDoc/PrCloseDocwithin the FOR loop. Whenever you reach 128 pages, you need to call PrCloseDoc to close the current document, and then PrPicFile to despool the (now full) spool file. Once this is done, a new document is opened, and everything continues as before.

FOR pageIndex := firstPage TO kNumberOfPages - 1 DO
BEGIN
    (* If we are on page number 128, 
       we need to close and reopen the document *)
    IF (pageIndex - firstPage) MOD iPFMaxPgs = 0 THEN
    BEGIN
        (* Make sure there is a document open before
           calling PrCloseDoc! i.e. if this is the first
           page, don't call PrCloseDoc... *)
        IF pageIndex <> firstPage THEN 
        BEGIN
            PrCloseDoc(...);
            PrPicFile(...);
        END;
        (* Now open a fresh, 128 page spool file. *)
        PrOpenDoc(...);
    END;
    (* Call PrOpenPage/PrClosePage for each page of the document. *)
    PrOpenPage(...);
    PrintAPage(...);
    PrClosePage(...);
END;
(* Finally, close the document and despool the spool file.*)
PrCloseDoc(...);
PrPicFile(...);
.
.
.

Pretty straightforward, but you'd be surprised how many developers the great implementors have caught with this one. Using the above method, you can safely print large documents on any device, without having to worry about overflowing the spool file. As for your neighbors, you could always put a Pause/Continue button in your Printing Status dialog, but then, where's the fun in that?

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Netflix Games expands its catalogue with...
It is a good time to be a Netflix subscriber this month. I presume there's a good show or two, but we are, of course, talking about their gaming service that seems to be picking up steam lately. May is adding five new titles, and there are some... | Read more »
Seven Knights Idle Adventure drafts in a...
Seven Knights Idle Adventure is opening up more stages, passing the 15k mark, and players may find themselves in need of more help to clear these higher stages. Well, the cavalry has arrived with the introduction of the Legendary Hero Iris, as... | Read more »
AFK Arena celebrates five years of 100 m...
Lilith Games is quite the behemoth when it comes to mobile games, with Rise of Kingdom and Dislyte firmly planting them as a bit name. Also up there is AFK Arena, which is celebrating a double whammy of its 5th anniversary, as well as blazing past... | Read more »
Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »

Price Scanner via MacPrices.net

Apple introduces the new M4-powered 11-inch a...
Today, Apple revealed the new 2024 M4 iPad Pro series, boasting a surprisingly thin and light design that pushes the boundaries of portability and performance. Offered in silver and space black... Read more
Apple introduces the new 2024 11-inch and 13-...
Apple has unveiled the revamped 11-inch and brand-new 13-inch iPad Air models, upgraded with the M2 chip. Marking the first time it’s offered in two sizes, the 11-inch iPad Air retains its super-... Read more
Apple discontinues 9th-gen iPad, drops prices...
With today’s introduction of the new 2024 iPad Airs and iPad Pros, Apple has (finally) discontinued the older 9th-generation iPad with a home button. In response, they also dropped prices on 10th-... Read more
Apple AirPods on sale for record-low prices t...
Best Buy has Apple AirPods on sale for record-low prices today starting at only $79. Buy online and choose free shipping or free local store pickup (if available). Sale price for online orders only,... Read more
13-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices, along with Amazon’s, are the lowest currently available for new 13″... Read more
Amazon is offering a $100 discount on every 1...
Amazon has every configuration and color of Apple’s 13″ M3 MacBook Air on sale for $100 off MSRP, now starting at $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD): $999 $100 off... Read more
Sunday Sale: Take $150 off every 15-inch M3 M...
Amazon is now offering a $150 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 15″ M3 MacBook... Read more
Apple’s 24-inch M3 iMacs are on sale for $150...
Amazon is offering a $150 discount on Apple’s new M3-powered 24″ iMacs. Prices start at $1149 for models with 8GB of RAM and 256GB of storage: – 24″ M3 iMac/8-core GPU/8GB/256GB: $1149.99, $150 off... Read more
Verizon has Apple AirPods on sale this weeken...
Verizon has Apple AirPods on sale for up to 31% off MSRP on their online store this weekend. Their prices are the lowest price available for AirPods from any Apple retailer. Verizon service is not... Read more
Apple has 15-inch M2 MacBook Airs available s...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs available starting at $1019 and ranging up to $300 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at Apple.... Read more

Jobs Board

IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: May 8, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Nurse Anesthetist - *Apple* Hill Surgery Ce...
Nurse Anesthetist - Apple Hill Surgery Center Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
LPN-Physician Office Nurse - Orthopedics- *Ap...
LPN-Physician Office Nurse - Orthopedics- Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Read more
Supervisor/Therapist Rehabilitation Medicine...
Supervisor/Therapist Rehabilitation Medicine - Apple Hill (Outpatient Clinic) - Day Location: York Hospital, York, PA Schedule: Full Time Sign-On Bonus Eligible Read more
BBW Sales Support- *Apple* Blossom Mall - Ba...
BBW Sales Support- APPLE BLOSSOM MALL Brand: Bath & Body Works Location: Winchester, VA, US Location Type: On-site Job ID: 04388 Job Area: Store: Sales and Support Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.