home *** CD-ROM | disk | FTP | other *** search
/ The Mother of All Windows Books / CD-MOM.iso / cd_mom / newsletr / vbz / vbz1-3 / prntform.bas < prev    next >
BASIC Source File  |  1993-06-25  |  3KB  |  106 lines

  1.  
  2. Sub PrintFormatted (TheText, Title, TopMargin, LeftMargin, BodyBottomMargin, BottomMargin, BaseFont, BaseFontSize, HeadlineMultiplier)
  3.     
  4.     printer.ScaleMode = 5       'inches
  5.     
  6.     printer.FontName = BaseFont
  7.     printer.FontBold = False
  8.     
  9.     PageCount = 1
  10.     cr$ = Chr$(13)
  11.     nl$ = Chr$(13) + Chr$(10)
  12.     TheText = TheText + cr$
  13.  
  14.             'Print a big title
  15.     CurSize = printer.FontSize
  16.     printer.FontSize = HeadlineMultiplier * CurSize
  17.     printer.FontBold = True
  18.     printer.CurrentY = TopMargin
  19.     printer.CurrentX = LeftMargin
  20.     printer.Print Command$ + nl$
  21.     printer.FontBold = False
  22.     printer.FontSize = CurSize
  23.     temp$ = TheText
  24.     
  25.             'Peel off one line at a time from the text from the clipboard
  26.     While Len(temp$) > 1
  27.         DidAFooter = False
  28.         prtstr$ = Left$(temp$, InStr(temp$, cr$) - 1)
  29.         rightamount = Len(temp$) - Len(prtstr$) - 2
  30.         If rightamount <= 0 Then
  31.             temp$ = ""
  32.         Else
  33.             temp$ = Right$(temp$, rightamount)
  34.         End If
  35.                 
  36.                 'Print each line
  37.         printer.CurrentX = LeftMargin
  38.         PrintIt prtstr$
  39.         ok = DoEvents()
  40.  
  41.             'New Page Routines:
  42.             'Would another line put us past the textbody bottom margin?
  43.         If printer.CurrentY + printer.TextHeight("J") > printer.ScaleHeight - BodyBottomMargin Then
  44.             printer.FontBold = True
  45.             printer.CurrentX = LeftMargin
  46.             printer.CurrentY = printer.ScaleHeight - (BottomMargin)
  47.             printer.Print Title + " - Page " + Format$(PageCount)
  48.             printer.FontBold = False
  49.             printer.NewPage
  50.             printer.CurrentY = TopMargin
  51.             PageCount = PageCount + 1
  52.             DidAFooter = True
  53.         End If
  54.     Wend
  55.  
  56.            
  57.              'You might need a footer for the last page
  58.     If DidAFooter = False Then
  59.         printer.FontBold = True
  60.         printer.CurrentY = printer.ScaleHeight - (BottomMargin)
  61.         printer.CurrentX = LeftMargin
  62.         printer.Print Title + " - Page " + Format$(PageCount)
  63.         printer.FontBold = False
  64.     End If
  65.             
  66.  
  67.     printer.EndDoc
  68.  
  69. End Sub
  70.  
  71. Sub PrintIt (txt)
  72.     If InStr(txt, "\") Then
  73.         For x = 1 To Len(txt)
  74.         
  75.             thechar = Mid$(txt, x, 1)
  76.             If thechar <> "\" Then
  77.                 chunk = chunk + thechar
  78.             Else
  79.                 printer.Print chunk;
  80.                 chunk = ""
  81.                 x = x + 1
  82.                 token = Mid$(txt, x, 1)
  83.                 Select Case token
  84.                     Case "b"
  85.                     printer.FontBold = False
  86.                     Case "B"
  87.                     printer.FontBold = True
  88.                     Case "i"
  89.                     printer.FontItalic = False
  90.                     Case "I"
  91.                     printer.FontItalic = True
  92.                     Case "U"
  93.                     printer.FontUnderline = True
  94.                     Case "u"
  95.                     printer.FontUnderline = False
  96.                 End Select
  97.              End If
  98.         Next
  99.         printer.Print chunk
  100.     Else
  101.         printer.Print txt
  102.     End If
  103.  
  104. End Sub
  105.  
  106.