revPrintText Answers
Rob Cozens
rcozens at pon.net
Sat Jun 1 18:51:01 EDT 2002
> >* At least 30% of this handler could be eliminated if I could find a
> >way to set the font & size Transcript uses when printing plain text.
>
>You can specify a template field from which the font, size, and style are
>taken:
>
> revPrintText myText,myHeader,myFooter,the long name of field "Example"
Hi All,
That one piece of information let me cut the handler size by 50+%
(from 44 lines to 21 lines). I was so pleased, especially since the
handler no longer goes to the library stack, that I added logic to
allow five page number placement options: Top right, bottom left,
bottom center, bottom right, or none.
on printTable
theTable,theHeader,theFontSize,theLineLength,extraMargin,pageNumberPosition,addedSpaceWidth,addedSpaceLocations
if theLineLength < 1 then put offset(return,theTable)-1 into theLineLength
if extraMargin is empty then put 36 into extraMargin else add 36 to
extraMargin
set cursor to watch
if addedSpaceWidth is not empty then put justifyString("
",addedSpaceWidth) into theSpacer
put empty into newTable
repeat for each line tableLine in theTable
put char 1 to theLineLength of tableLine into tableLine
if addedSpaceWidth > 0 then
repeat with x = the number of lines of addedSpaceLocations down to 1
put theSpacer after char (line x of addedSpaceLocations) of tableLine
end repeat
end if
put tableLine&return after newTable
end repeat
set the printMargins to extraMargin,108,extraMargin,36
set the textSize of field "Text Formatter" of card 1 of stack
"Serendipity Library.rev" to theFontSize
revShowPrintDialog true,true
switch pageNumberPosition
case "UR" -- Upper right
revPrintText newTable,(the short
date)&tab&"<b>"&theHeader&"</b>"&tab&"<%pagenumber%>",,the long name
of field "Text Formatter" of card 1 of stack "Serendipity Library.rev"
break
case "BL" -- Bottom left
revPrintText newTable,(the short
date)&tab&"<b>"&theHeader&"</b>","<%pagenumber%>",the long name of
field "Text Formatter" of card 1 of stack "Serendipity Library.rev"
break
case "BC" -- Bottom center
revPrintText newTable,(the short
date)&tab&"<b>"&theHeader&"</b>",tab&"<%pagenumber%>",the long name
of field "Text Formatter" of card 1 of stack "Serendipity Library.rev"
break
case "BR" -- Bottom right
revPrintText newTable,(the short
date)&tab&"<b>"&theHeader&"</b>",tab&tab&"<%pagenumber%>",the long
name of field "Text Formatter" of card 1 of stack "Serendipity
Library.rev"
break
default
revPrintText newTable,(the short
date)&tab&"<b>"&theHeader&"</b>",,the long name of field "Text
Formatter" of card 1 of stack "Serendipity Library.rev"
end switch
set cursor to hand
end printTable
--
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list