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

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.