home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Magazine 28 Bonus / CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin / data / shared.dir / 03105_Script_PRINTING < prev    next >
Text File  |  1996-06-21  |  6KB  |  156 lines

  1. -- --------------------------------------------------------------
  2. -- Handler printTextFromMac
  3.  
  4. on printTextFromMac theText
  5.   set charsPerLine = 85
  6.   set linesPerPage = 45
  7.   set charsPerPage = charsPerLine * linesPerPage
  8.   
  9.   openXObjHandler "print_X XObj"
  10.   put print_X(mnew) into printObj
  11.   
  12.   set titleStyle = 1 -- bold
  13.   set titleSize = 18
  14.   set titleFont = "Times"
  15.   
  16.   set hdrStyle = 0 -- normal
  17.   set hdrSize = 10
  18.   set hdrFont = "Times"
  19.   set hdrText = "Artrageous! ⌐1995 SoftKey International, Inc.                      Page #"
  20.   printObj(mSetHeaderStyle2,titleFont,titleSize,titleStyle)
  21.   printObj(mSetJustify2, 0) -- centered
  22.   
  23.   -- setting the "footerText" above the title because it doesn't seem to print as a footer
  24.   printObj(mSetHeaderStyle1,hdrFont,hdrSize,hdrStyle)
  25.   printObj(mSetJustify1, 1) -- left
  26.   
  27.   printObj(mSetBodyTop, 90) 
  28.   printObj(mSetBodyJustify, 1) -- left        
  29.   printObj(mSetBodyStyle, "Times", 12, 0)
  30.   
  31.   printPages(theText, charsPerPage, printObj, hdrText)
  32.   
  33.   printObj(mDispose)
  34.   closeXObjHandler "print_X XObj"
  35. end
  36.  
  37. -- --------------------------------------------------------------
  38. -- Handler printPages to be used by both the mac and the pc after
  39. -- specific properties for each have been set.
  40.  
  41.  
  42. on printPages theText, charsPerPage, printObj, hdrText
  43.   -- get the number of chars in the text
  44.   set charsInText = the number of chars in theText
  45.   
  46.   -- based on the number of chars per line and the number of lines
  47.   -- per page, get the number of pages to print.
  48.   set numPagesToPrint = charsInText / charsPerPage
  49.   if (charsInText mod charsPerPage >= 1) then
  50.     set numPagesToPrint = numPagesToPrint + 1
  51.   end if
  52.   
  53.   set firstCharInPage = 1
  54.   
  55.   -- print the pages one at a time
  56.   repeat with currentPage = 1 to numPagesToPrint
  57.     -- make sure the page end does not interrupt a word
  58.     set lastCharInPage = currentPage * charsPerPage
  59.     set Done = FALSE
  60.     repeat while not(Done)
  61.       set whichChar = char lastCharInPage of theText
  62.       if ((whichChar <> " ") and (whichChar <> EMPTY)) then
  63.         set lastCharInPage = lastCharInPage + 1
  64.       else
  65.         set Done = TRUE
  66.       end if
  67.     end repeat
  68.     
  69.     -- get the text of the current page
  70.     set currentPageText = char firstCharInPage to lastCharInPage of theText
  71.     
  72.     -- store the text of the current page in a text cast member
  73.     put currentPageText into field "printText"
  74.     
  75.     -- print the page (print the title of the topic for the first page only)
  76.     if (currentPage = 1) then
  77.       printObj(mPrintPage, hdrText & string(currentPage),the text of field "Topic Title",the text of cast "printText", "", 128)
  78.     else
  79.       printObj(mPrintPage, hdrText & string(currentPage), "",the text of cast "printText", "", 128)
  80.     end if
  81.     
  82.     -- set the first character of the following page
  83.     set firstCharInPage = lastCharInPage + 1
  84.   end repeat
  85. end
  86.  
  87. -- --------------------------------------------------------------
  88. -- Handler printTextFromPC
  89.  
  90. on printTextFromPC theText
  91.   openXObjHandler "print_X.dll"
  92.   put print_X(mnew) into printObj
  93.   
  94.   set charsPerLine = 75
  95.   set linesPerPage = 40
  96.   set charsPerPage = charsPerLine * linesPerPage
  97.   
  98.   set titleStyle = 1 -- bold
  99.   set titleSize = 18
  100.   set titleFont = "Times"
  101.   
  102.   set hdrStyle = 0 -- normal
  103.   set hdrSize = 10
  104.   set hdrFont = "Times"
  105.   set hdrText = "Artrageous! ⌐1995 SoftKey International, Inc                        Page #"
  106.   
  107.   printObj(mSetHeaderStyle2,titleFont,titleSize,titleStyle)
  108.   printObj(mSetJustify2, 0) -- centered
  109.   printObj(mSetHeaderTop2,20)
  110.   
  111.   -- setting the "footerText" above the title because it doesn't seem to print as a footer
  112.   printObj(mSetHeaderStyle1,hdrFont,hdrSize,hdrStyle)
  113.   printObj(mSetJustify1, 1) -- left
  114.   printObj(mSetHeaderTop1,5)
  115.   
  116.   printObj(mSetBodyTop, 80) 
  117.   printObj(mSetBodyJustify, 1) -- left        
  118.   printObj(mSetBodyStyle, "Times", 12, 0)
  119.   
  120.   printPages(theText, charsPerPage, printObj, hdrText)
  121.   
  122.   printObj(mDispose)
  123.   closeXObjHandler "print_X.dll"
  124. end
  125.  
  126. -- --------------------------------------------------------------
  127. -- Handler print_X(mDescribe)
  128.  
  129.  
  130. --  I      mNew
  131. --  SSSSSI mPrintPage, hdr1, hdr2, bodyText, pictRsrcPath, rsrcID
  132. --  SSSSSI mPrintFile, hdr1, hdr2, bodyTextPath, pictRsrcPath, rsrcID
  133. --  XI     mSetHeaderMargin, margin          -- set the margin for the headers
  134. --  XII    mSetBodyTextMargin, left, right   -- set left and right margin of the body text
  135. --  XI     mSetHeaderTop1, topPosition  -- set the upper start point for header 1
  136. --  XI     mSetHeaderTop2, topPosition  -- set the upper start point for header 2
  137. --  XI     mSetJustify1, j              -- set the justification for header 1
  138. --  XI     mSetJustify2, j              -- set the justification for header 1
  139. --  XSII   mSetHeaderStyle1, fontName, size, style  -- font style for header 1
  140. --  XSII   mSetHeaderStyle2, fontName, size, style  -- font style for header 2
  141. --  XI     mSetBodyTop, topPosition              -- set the upper start point for body
  142. --  XI     mSetBodyJustify, j                    -- set the justification for the body text
  143. --  XSII   mSetBodyStyle, fontName, size, style   -- font style for main body text
  144. --  XI     mSetPictTop, topPosition              -- set the upper start point for image
  145.  
  146. -- To print a string, or text castmember, use mPrintPage
  147. --    gXObject(mPrintPage, "h1", "h2", the text of cast "scheherazade", the pathName & "picts", 128)
  148. --
  149. -- To print a file (perhaps created using fileIo), use mPrintFile
  150. --    gXObject(mPrintFile, "h1", "h2", the pathName & "tempFile", the pathName & "picts", 128)
  151. --
  152. -- Remember that pictRsrcPath is the full path to a resource file (not PICT file)
  153. -- If no picture is desired then use "" for pictRsrcPath
  154. --
  155. -- For text and header justification : 0=center, 1=left, 2=right
  156. -- For text and header style : 0=normal, 1=bold, 2=italic, 4=underline (add to combine)