print screens example handler (Rev 1.1.1)

Alex Rice alrice at ARCplanning.com
Fri Apr 4 00:18:01 CST 2003


On Tuesday, March 4, 2003, at 08:15  AM, Alex Rice wrote:

> on nicePrintScreens
>   set the cursor to watch
>   --
>   -- create a new stack for performing print screens layout
>   --
>   lock messages
>   new invisible stack "PrintScreens"
>   -- don't keep stack in memory after we are done with it
>   set the destroyStack of stack "PrintScreens" to true
>   -- don't use printer fonts- yet.
>   set the formatForPrinting of stack "PrintScreens" to false
^
this is the default of formatForPrinting  anyways

>   -- dont bother buffering since we are not actually displaying this 
> stack on screen
>   set the alwaysBuffer of stack "PrintScreens" to false
>   -- make it our size
>   set the width of stack "PrintScreens" to the width of this stack
>   set the height of stack "PrintScreens" to the height of this stack
>   -- copy selected cards
>   repeat with tCardNumber = 1 to the number of cards in this stack
>     -- here you could test the card to see if it's supposed to be 
> printed
>     put "true" into tActive
>     if tActive then
>       copy card tCardNumber of this stack to stack "PrintScreens"
>     end if
>   end repeat
>   -- get rid of the first card in the stack
>   -- it is blank and was put there when the stack was created.
>   delete card 1 of stack "PrintScreens"
>   -- yes, use printer fonts
>   set the formatForPrinting of stack "PrintScreens" to true

^
Here I am setting formatForPrinting to true while the stack is still in 
memory. The docs say this is BAD and sure enough- I was seeing all 
kinds of bizarre behavior. Varying from a hung app to a runtime crash 
with "integer division by zero".  This works a whole lot better:

set the destroyStack of stack "PrintScreens" to true
save stack "PrintScreens" as tFilename
close stack "PrintScreens" -- will purge
set the formatForPrinting of stack tFilename to true
go stack tFilename


Alex Rice, Software Developer
Architectural Research Consultants, Inc.
alrice at ARCplanning.com
alrice at swcp.com






More information about the use-livecode mailing list