home *** CD-ROM | disk | FTP | other *** search
/ Using Asymetrix Multimedi…ool Book Special Edition / SE_UAMT.iso / examples / ch23.tbk (.txt) < prev    next >
Encoding:
Asymetrix ToolBook File  |  1995-11-02  |  231.3 KB  |  6,061 lines

  1. <BookPath>
  2. :HDMEDIAPATH
  3. System
  4. 1,    #>
  5. MTB40DLG.DLL
  6. TB40DOS.DLL
  7. fName
  8. c:\mtb40\samples\
  9. getFileList
  10. sortTextlines
  11. TB40DLG.DLL
  12. fScript
  13. *.tbk
  14. MTB40DOS.DLL
  15. wsortTextlines
  16. getFileList
  17. buttonClick
  18. TO HANDLE buttonClick
  19. ZLONG i
  20. ZSTRING f,fl,p
  21. linkDLL "TB40DOS.
  22. "getFileList(
  23. GsortTextlines(
  24. p = "c:\mtb40\samples\"
  25. f = p & "*.tbk"
  26. fl = 
  27. fl = 
  28. --trap
  29. "fName" = 
  30. "fScript" = 
  31. (p &(
  32. unlinkDLL "MTB40DLG.
  33. fname
  34. fscript
  35. fscript
  36. CDBSE&File
  37. &Open...    Ctrl+O
  38. &Save    Ctrl+S
  39. Save &As...
  40. saveas
  41. &Import...
  42. import
  43. &Export...
  44. export
  45. Print Set&up...
  46. printsetup
  47. &Print Pages...    Ctrl+P
  48. printpages
  49. Prin&t Report...
  50. printreport
  51. Send &Mail...
  52. sendmail
  53. &Run...
  54. E&xit    Alt+F4
  55. &Edit
  56. &Undo    Ctrl+Z
  57. Cu&t    Ctrl+X
  58. &Copy    Ctrl+C
  59. &Paste    Ctrl+V
  60. paste
  61. C&lear    Del
  62. clear
  63. Select &All    Shift+F9
  64. selectall
  65. Select Pa&ge    Shift+F12
  66. selectpage
  67. &Size to Page    F11
  68. sizetopage
  69. F&ind...    F5
  70. Re&place...
  71. replace
  72. Aut&hor    F3
  73. author
  74. &Text
  75. &Character...    F6
  76. character
  77. &Paragraph...    F7
  78. paragraph
  79. &Regular    Ctrl+Space
  80. regular
  81. &Bold    Ctrl+B
  82. &Italic    Ctrl+I
  83. italic
  84. &Underline    Ctrl+U
  85. underline
  86. Stri&keout    Ctrl+K
  87. strikeout
  88. Superscrip&t/Subscript
  89. superscriptSubscript
  90. &Normal Script
  91. normalscript
  92. Su&bscript    Ctrl+L
  93. subscript
  94. Su&perscript    Ctrl+Shift+L
  95. superscript
  96. &Show Hotwords    F9
  97. showhotwords
  98. &Page
  99. &Next    Alt+Right
  100. &Previous    Alt+Left
  101. previous
  102. &First    Alt+Up
  103. first
  104. &Last    Alt+Down
  105. &Back    Shift+F2
  106. &History...    Ctrl+F2
  107. history
  108. N&ew Page    Ctrl+N
  109. newpage
  110. &Help
  111. &Contents    F1
  112. contents
  113. Status &Bar    F12
  114. statusbar
  115. `E`3!
  116. filename
  117. NSTALL LOG 
  118. MOUSE      
  119. UTOEXECB~K 
  120. ONFIG  B~K 
  121. PMACLAN5   
  122. NSTALL TMP 
  123. ONFIG  1   
  124. UTOEXEC1   
  125. ONFIG  2   
  126. UTOEXEC2   
  127. UTOEXEC3   
  128. PMACLAN VO
  129. DIALOG.TBK
  130. DIALOG.TBK
  131. Transfer
  132. ge id 8
  133. Button
  134. Field
  135. ge id 8
  136. page "button page"
  137. page "Field page"
  138. unlinkDLL "MTB30DLG.
  139. field page
  140. button page
  141. splunge
  142. field page
  143. this is some text
  144. button page
  145. transfer
  146. --TO HANDLE buttonClick
  147. <> NULL
  148. "f2"= 
  149. --END 
  150. Transfer
  151. --TO HANDLE buttonClick
  152. <> NULL
  153. "f2"= 
  154. --END 
  155. goats
  156. 12790
  157. stoats
  158. buttonClick
  159. TO HANDLE buttonClick
  160. ZINT x,y
  161. 4STRING z[4][2]
  162.     x = 122
  163.     y = (525 - x) * 4
  164.     z[1][1] = "12790"
  165.     z[1][2] = "cats"
  166.     z[2][1] = "34"
  167.     z[2][2] = "bats"
  168.     z[3][1] = 455
  169.     z[3][2] = "stoats"
  170.     z[4][1] = "9765"
  171.     z[4][2] = "goats"
  172. <> NULL
  173. "f2"= 
  174. uttonClick
  175. TO HANDLE buttonClick
  176. <> NULL
  177. "f2"= 
  178. enterBackground
  179. leaveBackground
  180. TO HANDLE 
  181. = 70,105
  182. = 70,160
  183. isOpen 
  184.         close 
  185. [ToolBook]
  186. startupSysBooks=C:\MTB30\mtb30.sbk
  187. startupAutoScriptFile=
  188. splunged
  189. Entry:
  190. *ClassTbl*
  191. *ClassEntry*
  192. *PTABLE*
  193. *WINDOWSEG*
  194. *ICONRESTAB*
  195. *ICONRESSEG*
  196. *ICONRES*
  197. Background
  198. *OBJTABLE*
  199. *IDTABLE*
  200. *NAMETAB*
  201. Rectangle
  202. Ellipse
  203. RoundedRectangle
  204. Polygon
  205. IrregularPolygon
  206. AngledLine
  207. Curve
  208. PaintObject
  209. Picture
  210. Group
  211. Stage
  212. Button
  213. Viewer
  214. ComboBox
  215. Field
  216. RecordField
  217. Hotword
  218. *RHOTWORD*
  219. *TbxBase*
  220. <BookPath>
  221. :HDMEDIAPATH
  222. System
  223. ame" to menu "contents" at author with helptext\
  224.          "Changes name of current chapter."
  225.         add menuitem "" to menu "contents" at author
  226.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  227.          "Adds new topic to this chapter."
  228.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  229.          "Changes name of topic chapter."
  230.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  231.          "Displays help on using this template."
  232.         if firstTime of this book is not false
  233.             open viewer "outline"
  234.             send rebuildStructure
  235.             firstTime of this book = false
  236.         end
  237.     if not animSysbookLoaded()
  238.         request "The path animation sysbook is not loaded. Animations in the ""Path Animation"" sections will not run. Be sure that either mtb30.sbk or mtb30ani.sbk are included in your startupSysbooks."
  239.     hide button "help" of page "toolbar"
  240.     -- initialize checkmarks
  241.     bk = topicsBackground()
  242.     step i from 1 to pagecount of bk
  243.         set visited of page i of bk to false
  244.     set checked of group "tableofcontents" of page "tableOfContents" to false
  245.     if syslevel is author
  246.         send reader
  247. to handle entermenu menuName,menuAlias
  248.     if menuName is "contents" and syslevel is author
  249.         if this background is chaptersBackground() 
  250.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  251.         else
  252.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  253.         end
  254.         if this background is TopicsBackground() 
  255.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  256.         else
  257.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  258.         end
  259.         if visible of viewer "outline"
  260.             check menuitem "outline"  in menu "contents" at author
  261.         else
  262.             uncheck menuitem "outline"  in menu "contents" at author
  263.         end
  264.     forward
  265. to handle leaveapplication
  266.     remove menu "Contents" at author
  267.     remove menuitem "helpTemplate" in menu "help" at author
  268.     forward
  269. to handle author
  270.     if isOpen of viewer "outline"
  271.         set fw to focusWindow
  272.         show viewer "outline"
  273.         set focusWindow to fw
  274.     show button "help" of page "toolbar"
  275.     forward
  276. to handle reader
  277.     forward
  278.     if isOpen of viewer "outline"
  279.         hide viewer "outline"
  280.     hide button "help" of page "toolbar"
  281.     send sizeToPage
  282. to handle outline
  283.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  284.     if mstate is true
  285.         if isOpen of viewer "outline"
  286.             close viewer "outline"
  287.         end
  288.     else
  289.         open viewer "outline"
  290.         send rebuildStructure
  291.         show viewer "outline"
  292. -- if a newbackground is inserted into the content area,
  293. -- move it beyond the content area
  294. to handle newBackground
  295.     get chapterCount of this book
  296.     if it < chapterLimit()
  297.         forward
  298.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  299.                        pagenumber of last page of topicsBackground())
  300.         if pagenumber of this page < lastPage
  301.             pageNumber of this page = lastPage
  302.         end
  303.     else
  304.         request "This template is limited to" && chapterLimit() && "chapters."
  305. --================ Utility handlers ===================
  306. -- returns number of chapters allowed in this template
  307. to get chapterLimit
  308.     return 8
  309. -- returns the background reference for the chapter headings background
  310. to get chaptersBackground
  311.     return background "chapter headings"
  312. -- returns the background reference for the chapter topics background
  313. to get topicsBackground
  314.     return background "topics"
  315. to handle rebuildStructure updatePalette
  316.     if updatePalette is null
  317.         updatePalette = true
  318.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  319.     pageNumber of page "tableofcontents" = 1
  320.     pagenumber of first page of chaptersBackground() = 2
  321.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  322.                    pagenumber of last page of topicsBackground())
  323.     pageCounter = 2
  324.     chapterCount = 0
  325.     while pageCounter <= lastPage
  326.         curPage = page pageCounter
  327.         curPageId = idnumber of curPage
  328.         curBackground = parent of curPage
  329.         pagelabel = label of curPage
  330.         conditions
  331.             when curBackground is chaptersBackground()
  332.                 increment chapterCount
  333.                 if prevChapterHeadingPage is not NULL
  334.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  335.                     clear pagesOfEachChapter
  336.                 end
  337.                 prevChapterHeadingPage = curPage
  338.                 curChapterId = curPageId
  339.                 myChapterID of curPage = curChapterID
  340.                 if chapterList is not null
  341.                     put crlf after chapterList
  342.                 end
  343.                 put curPageId & "," & pageLabel after chapterList
  344.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  345.                 increment pageCounter
  346.             when curBackground is topicsBackground()
  347.                 if pagesOfEachChapter is not null
  348.                     put "," after pagesOfEachChapter
  349.                 end
  350.                 put idnumber of curPage after pagesOfEachChapter
  351.                 myChapterID of curPage = curChapterID
  352.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  353.                 increment pageCounter
  354.         else
  355.             -- this page is not of either background. Move it beyond both backgrounds
  356.             pageNumber of curPage = lastPage
  357.             decrement lastPage    
  358.         end
  359.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  360.     voutline of group "tableOfContents" of page "tableOfContents" = chapterList
  361.     clear last char of listBoxText
  362.     clear last char of listBoxText
  363.     if updatePalette
  364.         if isOpen of viewer "outline"
  365.             send initPage listBoxText to currentPage of viewer "outline"
  366.         end
  367.     in mainWindow
  368.         send initPage to this page
  369.     chapterCount of this book = chapterCount
  370. -- Used to get the text before a tab of a textline
  371. -- (in the list box of a dialog viewer, tab is used 
  372. -- to store extra information that gets clipped by the 
  373. -- right side of the field)
  374. to get extractName t
  375.     if first char of t is tab
  376.         clear first char of t
  377.     tabOffset = offset(tab,t)
  378.     if tabOffset is 0
  379.         return null
  380.     else
  381.         return chars 1 to tabOffset-1 of t
  382. -- Used to get the text beyond a tab of a textline
  383. to get extractID t
  384.     lastTabLoc = charcount(t)
  385.         decrement lastTabLoc
  386.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  387.     if lastTabLoc <=0
  388.         return null
  389.     else
  390.         return chars lastTabLoc+1 to charcount(t) of t
  391. -- returns the numerical location of an item in a list
  392. to get itemOffset itm,lst
  393.     step i from 1 to itemcount(lst)
  394.         pop lst
  395.         if it = itm
  396.             return i
  397.         end
  398.     return 0
  399. -- returns a gray color
  400. to get middleGray
  401.     return 240,63.5,2.1875
  402. -- returns dark blue
  403. to get darkBlue
  404.     return 240,25.125,100
  405. -- returns a string of tabs. This serves a spacer between the 
  406. -- label of a page and the idnumber on each line in the listbox. 
  407. -- This is used so the idnumber is clipped and not visible
  408. to get tabSpacer
  409.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  410. --============= Navigation and menu messages =============
  411. -- tableOfContents message sent by toolbar
  412. -- when the tableOfContents button is pressed
  413. to handle tableOfContents
  414.     pref = page "tableOfContents"
  415.     send updatechecks to group "tableofcontents" of pref
  416.     go to pref
  417. to handle helpTemplate
  418.     mydir = name of self
  419.         clear last char of mydir
  420.     until last char of mydir is "\" or mydir is null
  421.     sen = sysErrorNumber
  422.     se = sysError
  423.     sysErrorNumber = 0
  424.     ss = sysSuspend
  425.     syssuspend = false
  426.     bref = book (mydir&"tmplhelp.tbk")
  427.     syssuspend = ss
  428.     if sysErrorNumber is not 0
  429.         request "Cannot find book TMPLHELP.TBK"
  430.     else
  431.         vref = viewer "help" of bref
  432.         set defaultpage of vref to page "cbt1" of bref
  433.         open vref
  434.         show vref
  435.     sysErrorNumber = sen
  436.     sysError = se
  437. to handle initPage
  438. to handle newChapter promptForName
  439.     get chapterCount of this book
  440.     if it < chapterLimit()
  441.         if promptForName is null
  442.             promptForName = true
  443.         end
  444.         chapterName = "Untitled"
  445.         if promptForName
  446.             ask "Enter new chapter name." with chapterName
  447.             if syserror = cancel
  448.                 break
  449.             end
  450.             chapterName = it
  451.         end
  452.         in mainwindow
  453.             ls = lockscreen of this window
  454.             lockscreen of this window = true
  455.             -- go to a clean page so that leavePage messages are sent
  456.             -- then suspend messages and navigate to the last page of the 
  457.             -- appropriate background so that enterPage messages are not sent
  458.             go to page 1
  459.             ssm = syssuspendmessages
  460.             syssuspendmessages = true
  461.             go to last page of chaptersBackground()
  462.             send newPage
  463.             syssuspendmessages = ssm
  464.             set label of this page to chapterName
  465.             lastPage = max(pagenumber of last page of chaptersBackground(),\
  466.                            pagenumber of last page of topicsBackground())
  467.             set pageNumber of this page to lastPage
  468.             send rebuildStructure
  469.             send enterPage to this page
  470.             set enabled of button "tableOfContents" of page "toolbar" to true
  471.             lockscreen of this window = ls
  472.         end
  473.     else
  474.         request "This template is limited to" && chapterLimit() && "chapters."
  475. to handle newTopic pageNum
  476.     chapterName = "Untitled"
  477.     if pageNum is null
  478.         ask "Enter new topic name." with chapterName
  479.         if syserror = cancel
  480.             break
  481.         end
  482.         chapterName = it
  483.     in mainWindow
  484.         if pageNum is null
  485.             conditions
  486.                 when this background is chaptersBackground()
  487.                 when this background is topicsBackground()
  488.                     pageNum = pageNumber of this page
  489.             else
  490.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  491.                                pagenumber of last page of topicsBackground())
  492.                 pageNum = lastPage
  493.             end
  494.         end
  495.         ls = lockscreen of this window
  496.         lockscreen of this window = true
  497.         -- go to a clean page so that leavePage messages are sent
  498.         -- then suspend messages and navigate to the last page of the 
  499.         -- appropriate background so that enterPage messages are not sent
  500.         go to page 1
  501.         ssm = syssuspendmessages
  502.         syssuspendmessages = true
  503.         if this background is not topicsBackground()
  504.             go to last page of topicsBackground()
  505.         end
  506.         send newPage
  507.         syssuspendmessages = ssm
  508.         set label of this page to chapterName
  509.         set pageNumber of this page to pageNum+1
  510.         send rebuildStructure
  511.         send enterPage to this page
  512.         set enabled of button "tableOfContents" of page "toolbar" to true
  513.         lockscreen of this window = ls
  514. to handle changeName
  515.     ask "Enter new name." with label of this page
  516.     if syserror = cancel
  517.         break
  518.     label of this page = it
  519.     send rebuildStructure
  520. to handle saveAs
  521.     firstTime of this book = true
  522.     forward
  523. to handle aboutAnimate
  524.     show viewer "about" as modal
  525. to get animSysbookLoaded
  526.     if sysbooks contains "mtb30.sbk" or sysbooks contains "mtb30anm.sbk"
  527.         return true
  528.     else
  529.         return false
  530. CBT_DEMO.TBK
  531. H)H)--
  532. --   Copyright 
  533.  1994  Asymetrix Corporation                      
  534. --                                                                     
  535. --   Asymetrix gives you permission to copy, revise, and reuse the     
  536. --   individual objects and scripts in this application in your own    
  537. --   applications.  You may not copy the entire book (or a             
  538. --   substantial part of it) for redistribution as your own product.   
  539. --                                                                     
  540. --   Asymetrix retains the copyright on the original elements of this   
  541. --   application. Include the notice "Portions of this application are 
  542. --   the copyright of Asymetrix Corporation" in your product if they   
  543. --   contain objects or scripts copied from this application.          
  544. --   Author: Joseph Brick                                              
  545. --   Last revision: 5/9/94
  546. to handle enterApplication
  547.     forward
  548.     sysHistoryRecord = true
  549.     go to page "introscreen"
  550.     if sysRuntime is false
  551.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  552.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  553.          "Displays/hides Template Outline palette."
  554.         add menuitem "" to menu "contents" at author
  555.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  556.          "Adds new chapter to this book."
  557.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  558.          "Changes name of current chapter."
  559.         add menuitem "" to menu "contents" at author
  560.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  561.          "Adds new topic to this chapter."
  562.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  563.          "Changes name of topic chapter."
  564.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  565.          "Displays help on using this template."
  566.         if firstTime of this book is not false
  567.             open viewer "outline"
  568.             send rebuildStructure
  569.             firstTime of this book = false
  570.         end
  571.     send reader
  572. to handle entermenu menuName,menuAlias
  573.     if menuName is "contents" and syslevel is author
  574.         if this background is chaptersBackground() 
  575.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  576.         else
  577.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  578.         end
  579.         if this background is TopicsBackground() 
  580.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  581.         else
  582.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  583.         end
  584.         if visible of viewer "outline"
  585.             check menuitem "outline"  in menu "contents" at author
  586.         else
  587.             uncheck menuitem "outline"  in menu "contents" at author
  588.         end
  589.     forward
  590. to handle leaveapplication
  591.     set syslockscreen to true
  592.     set captionBar of mainwindow to normal
  593.     set state of mainwindow to normal
  594.     remove menu "Contents" at author
  595.     remove menuitem "helpTemplate" in menu "help" at author
  596.     forward
  597. to handle author
  598.     if isOpen of viewer "outline"
  599.         set fw to focusWindow
  600.         show viewer "outline"
  601.         set focusWindow to fw
  602.     set state of mainwindow to normal
  603.     set captionBar of mainwindow to normal
  604.     forward
  605. to handle reader
  606.     forward
  607.     if isOpen of viewer "outline"
  608.         hide viewer "outline"
  609.     set captionBar of mainwindow to none
  610.     set state of mainwindow to maximized
  611. to handle outline
  612.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  613.     if mstate is true
  614.         if isOpen of viewer "outline"
  615.             close viewer "outline"
  616.         end
  617.     else
  618.         open viewer "outline"
  619.         send rebuildStructure
  620.         show viewer "outline"
  621. -- if a newbackground is inserted into the content area,
  622. -- move it beyond the content area
  623. to handle newBackground
  624.     forward
  625.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  626.                    pagenumber of last page of topicsBackground())
  627.     if pagenumber of this page < lastPage
  628.         pageNumber of this page = lastPage
  629. --================ Utility handlers ===================
  630. -- returns the background reference for the chapter headings background
  631. to get chaptersBackground
  632.     return background "chapterheadings"
  633. -- returns the background reference for the chapter topics background
  634. to get topicsBackground
  635.     return background "content"
  636. to handle rebuildStructure updatePalette
  637.     local chapterCounter
  638.     chapterCounter = 0
  639.     if updatePalette is null
  640.         updatePalette = true
  641.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  642.     pageNumber of page "introscreen" = 1
  643.     pagenumber of first page of chaptersBackground() = 2
  644.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  645.                    pagenumber of last page of topicsBackground())
  646.     pageCounter = 2
  647.     while pageCounter <= lastPage
  648.         curPage = page pageCounter
  649.         curPageId = idnumber of curPage
  650.         curBackground = parent of curPage
  651.         pagelabel = label of curPage
  652.         conditions
  653.             when curBackground is chaptersBackground()
  654.                 increment chapterCounter
  655.                 if prevChapterHeadingPage is not NULL
  656.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  657.                     clear pagesOfEachChapter
  658.                 end
  659.                 prevChapterHeadingPage = curPage
  660.                 curChapterId = curPageId
  661.                 myChapterID of curPage = curChapterID
  662.                 if chapterList is not null
  663.                     put crlf after chapterList
  664.                 end
  665.                 put curPageId & "," & pageLabel after chapterList
  666.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  667.                 increment pageCounter
  668.             when curBackground is topicsBackground()
  669.                 chapter of curPage = chapterCounter
  670.                 if pagesOfEachChapter is not null
  671.                     put "," after pagesOfEachChapter
  672.                 end
  673.                 put idnumber of curPage after pagesOfEachChapter
  674.                 myChapterID of curPage = curChapterID
  675.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  676.                 increment pageCounter
  677.         else
  678.             -- this page is not of either background. Move it beyond both backgrounds
  679.             pageNumber of curPage = lastPage
  680.             decrement lastPage    
  681.         end
  682.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  683.     voutline of group "tableOfContents" of background "Content" = chapterList
  684.     clear last char of listBoxText
  685.     clear last char of listBoxText
  686.     if updatePalette
  687.         if isOpen of viewer "outline"
  688.             send initPage listBoxText to currentPage of viewer "outline"
  689.             in mainWindow
  690.                 send enterpage to this page
  691.             end
  692.         end
  693. -- Used to get the text before a tab of a textline
  694. -- (in the list box of a dialog viewer, tab is used 
  695. -- to store extra information that gets clipped by the 
  696. -- right side of the field)
  697. to get extractName t
  698.     if first char of t is tab
  699.         clear first char of t
  700.     tabOffset = offset(tab,t)
  701.     if tabOffset is 0
  702.         return null
  703.     else
  704.         return chars 1 to tabOffset-1 of t
  705. -- Used to get the text beyond a tab of a textline
  706. to get extractID t
  707.     lastTabLoc = charcount(t)
  708.         decrement lastTabLoc
  709.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  710.     if lastTabLoc <=0
  711.         return null
  712.     else
  713.         return chars lastTabLoc+1 to charcount(t) of t
  714. -- returns the numerical location of an item in a list
  715. to get itemOffset itm,lst
  716.     step i from 1 to itemcount(lst)
  717.         pop lst
  718.         if it = itm
  719.             return i
  720.         end
  721.     return 0
  722. -- returns a gray color
  723. to get middleGray
  724.     return 240,63.5,2.1875
  725. -- returns dark blue
  726. to get darkBlue
  727.     return 240,25.125,100
  728. -- returns a string of tabs. This serves a spacer between the 
  729. -- label of a page and the idnumber on each line in the listbox. 
  730. -- This is used so the idnumber is clipped and not visible
  731. to get tabSpacer
  732.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  733. to handle helpTemplate
  734.     mydir = name of self
  735.         clear last char of mydir
  736.     until last char of mydir is "\" or mydir is null
  737.     sen = sysErrorNumber
  738.     se = sysError
  739.     sysErrorNumber = 0
  740.     ss = sysSuspend
  741.     syssuspend = false
  742.     bref = book (mydir&"tmplhelp.tbk")
  743.     syssuspend = ss
  744.     if sysErrorNumber is not 0
  745.         request "Cannot find book TMPLHELP.TBK"
  746.     else
  747.         vref = viewer "help" of bref
  748.         set defaultpage of vref to page "cbt1" of bref
  749.         open vref
  750.         show vref
  751.     sysErrorNumber = sen
  752.     sysError = se
  753. to handle initPage
  754. to handle newChapter promptForName
  755.     if promptForName is null
  756.         promptForName = true
  757.     chapterName = "Untitled"
  758.     if promptForName
  759.         ask "Enter new chapter name." with chapterName
  760.         if syserror = cancel
  761.             break
  762.         end
  763.         chapterName = it
  764.     in mainwindow
  765.         ls = lockscreen of this window
  766.         lockscreen of this window = true
  767.         go to last page of chaptersBackground()
  768.         ssm = syssuspendmessages
  769.         syssuspendmessages = true
  770.         send newPage
  771.         syssuspendmessages = ssm
  772.         set label of this page to chapterName
  773.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  774.                        pagenumber of last page of topicsBackground())
  775.         set pageNumber of this page to lastPage
  776.         send rebuildStructure
  777.         send enterPage to this page
  778.         lockscreen of this window = ls
  779. to handle newTopic pageNum
  780.     chapterName = "Untitled"
  781.     if pageNum is null
  782.         ask "Enter new topic name." with chapterName
  783.         if syserror = cancel
  784.             break
  785.         end
  786.         chapterName = it
  787.     in mainWindow
  788.         if pageNum is null
  789.             conditions
  790.                 when this background is chaptersBackground()
  791.                 when this background is topicsBackground()
  792.                     pageNum = pageNumber of this page
  793.             else
  794.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  795.                                pagenumber of last page of topicsBackground())
  796.                 pageNum = lastPage
  797.             end
  798.         end
  799.         ls = lockscreen of this window
  800.         lockscreen of this window = true
  801.         if this background is not topicsBackground()
  802.             go to last page of topicsBackground()
  803.         end
  804.         ssm = syssuspendmessages
  805.         syssuspendmessages = true
  806.         send newPage
  807.         syssuspendmessages = ssm
  808.         set label of this page to chapterName
  809.         set pageNumber of this page to pageNum+1
  810.         send rebuildStructure
  811.         send enterPage to this page
  812.         lockscreen of this window = ls
  813. to handle changeName
  814.     ask "Enter new name." with label of this page
  815.     if syserror = cancel
  816.         break
  817.     label of this page = it
  818.     send rebuildStructure
  819. to handle sizeToPage
  820.     if syslevel is AUTHOR
  821.         forward
  822. CBT_TIPS.TBK
  823. --==================== Standard ToolBook messages ===================
  824. to handle enterApplication
  825.     forward
  826.     -- link needed dll's
  827.     linkDLL "tb30win.dll"
  828.         int displayBitsPerPixel()
  829.     -- these gdi calls are used for drawing separator line
  830.     linkDLL "gdi"
  831.         int getDeviceCaps(word,int)
  832.         dword moveTo(word,int,int)
  833.         int lineTo(word,int,int)
  834.         int setROP2(word,int)
  835.         word createPen(int,int,dword)
  836.         int deleteObject(word)
  837.         word selectObject(word,word)
  838.     linkdll user
  839.         word getDC(word)
  840.         int releaseDC(word,word)
  841.     if sysruntime is false
  842.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  843.          "Displays help on using this template."
  844.     -- set backcolor (a "to set" handler, below) depending on
  845.     -- the number of colors displayed.
  846.     get numColors()
  847.     if it > 16 or it = 0
  848.         set backcolor of this book to darkerBlue()
  849.     else
  850.         set backcolor of this book to lighterBlue()
  851.     show viewer "navigationBar"
  852.     in viewer "navigationBar"
  853.         -- initialize combobox and field in navigation window
  854.         set text of combobox "categories" to "<All topics>"
  855.         send populate "All" to field "Topics"
  856.     if sysLevel is not "reader"
  857.         send reader
  858.     else
  859.         send hideControls
  860. to handle leaveApplication
  861.     remove menuitem "helpTemplate" in menu "help" at author
  862. -- show buttons for modifying book
  863. to handle author
  864.     forward
  865.     send showControls
  866. to handle showControls
  867.     show group "CategoryButtons" of page "Navigation"
  868.     set item 4 of bounds of field "topics" of page "Navigation" to \
  869.      item 2 of bounds of group "CategoryButtons" of page "Navigation" - 60
  870.     send sizetopage
  871. -- hide buttons for modifying book
  872. to handle reader
  873.     forward
  874.     send hideControls
  875. to handle hideControls
  876.     hide group "CategoryButtons" of page "Navigation"
  877.     set item 4 of bounds of field "topics" of page "Navigation" to \
  878.      item 4 of bounds of group "CategoryButtons" of page "Navigation"
  879.     send sizetopage
  880. to handle destroy
  881.     -- if a page is deleted, updates the category array (struct[][]) userProperty 
  882.     -- of this book.
  883.     -- Each row of the category array has the category name and a list
  884.     -- of the id numbers of pages belonging to that category. This handler
  885.     -- walks through the array, finding every instance of that id number.
  886.     -- when found, it removes it.
  887.     if object of target is "page" and name of parent of target is in "description and script,description and example,description only"
  888.         local x[][]
  889.         set x to categoryStruct of this book
  890.         set pageID to idnumber of target
  891.         step i from 1 to item 1 of dimensions(x)
  892.             get itemOffset(pageID,x[i][2])
  893.             if it > 0
  894.                 clear item it of x[i][2]
  895.             end
  896.         end
  897.         set categoryStruct of this book to x
  898.     forward
  899. to handle enterPage
  900.     forward
  901.     -- if this is a content background
  902.     if name of parent of this page is in "description and script,description and example,description only"
  903.         -- to ensure the recordfield is set to the label property
  904.         -- the label property holds the name of each topic
  905.         set fref to recordfield "subTopicName" of this page
  906.         if text of fref is not label of this page
  907.             set text of fref to label of this page
  908.         end
  909.         -- set the scroll of the recordfield, if necessary
  910.         set fref to recordfield "explanation"
  911.         if scroll of fref is not 0
  912.             set scroll of fref to 0
  913.         end
  914.         -- add/remove scrollbars, if necessary
  915.         set txtOver to textoverflow of fref
  916.         conditions
  917.             when txtOver > 0 and borderstyle of fref is "none"
  918.                 set borderstyle of fref to "scrolling"
  919.             when txtOver = 0 and borderstyle of fref is "scrolling"
  920.                 set borderstyle of fref to "none"
  921.         end
  922. to handle leavePage
  923.     forward
  924.     if name of parent of this page is in "description and script,description and example,description only"
  925.         set topic to text of recordfield "subTopicName"
  926.         if label of this page is not topic
  927.             set label of this page to topic
  928.         end
  929. --========================= Utility handlers ===========================
  930. -- returns the text before a tab
  931. to get extractName t
  932.     set tabOffset to offset(tab,t)
  933.     return chars 1 to tabOffset-1 of t
  934. -- returns the text following a tab
  935. to get extractID t
  936.     set lastTabLoc to charcount(t)
  937.         decrement lastTabLoc
  938.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  939.     if lastTabLoc <=0
  940.         return null
  941.     else
  942.         return chars lastTabLoc+1 to charcount(t) of t
  943. -- returns the offset of item itm in list lst
  944. to get itemOffset itm,lst
  945.     step i from 1 to itemcount(lst)
  946.         pop lst
  947.         if itm = it
  948.             return i
  949.         end
  950.     return 0
  951. -- removes all instances of a char from a string
  952. to get stripChar chr,strng
  953.     while strng contains chr
  954.         clear char offset(chr,strng) of strng
  955.     return strng
  956. -- returns the number of colors displayed
  957. to get numColors
  958.     hdc = getDC(windowhandle of mainWindow)
  959.     retval = getDeviceCaps(hdc,24)
  960.     get releaseDC(windowhandle of mainwindow,hdc)
  961.     return retval
  962. to get darkerBlue
  963.     return 212,79.1875,71.6875
  964. to get lighterBlue
  965.     return 180,75.125,100
  966. to set backColor to value
  967.     set bckgrnds to "intro,description and script,description and example,description only"
  968.     step i from 1 to itemcount(bckgrnds)
  969.         pop bckgrnds
  970.         set curBack to background it
  971.         if fillcolor of curBack is not value
  972.             set fillcolor of curBack to value
  973.         end
  974. --================ Handlers for dealing with array structure ============
  975. -- display the array in a request box.
  976. -- (used during authoring for debugging purposes)
  977. to handle showCategoryStruct
  978.     local x[][]
  979.     set x to categoryStruct of this book
  980.     local retval
  981.     step i from 1 to item 1 of dimensions(x)
  982.         put x[i][1] after retval
  983.         put tab & x[i][2] & crlf after retval
  984.     request retval
  985. --------------- these handers sort the array --------------------
  986. to handle twoDquicksort fArray[][],n,dtype
  987.     system stbk_noSwap
  988.     set stbk_noSwap to 0
  989.     send twoDquicksrt fArray, 1, item 1 of dimensions(fArray),n,dtype
  990. to handle twoDquicksrt fArray[][], l, r,n,dtype
  991.     system  stbk_noSwap
  992.     if r > l 
  993.         send swap  fArray, l, ((l+r) div 2)
  994.         set lst to l
  995.         step i from (l+1) to r
  996.             conditions
  997.                 when dtype is "text"
  998.                     set test to fArray[i][n] < fArray[l][n] as text
  999.                 when dtype is "date"
  1000.                     set test to fArray[i][n] < fArray[l][n] as date
  1001.                 else
  1002.                     set test to fArray[i][n] < fArray[l][n] as number
  1003.             end
  1004.             if test
  1005.                 increment lst
  1006.                 send swap fArray, lst, i
  1007.             else
  1008.                 increment stbk_noswap
  1009.             end if
  1010.         end step
  1011.         send swap fArray,l,lst 
  1012.            
  1013.            send twoDquicksrt fArray, l, lst-1,n,dtype
  1014.         send twoDquicksrt fArray, lst+1,r,n,dtype
  1015.        end
  1016. to handle swap fArray[][], a, b
  1017.     local temp
  1018.     step i from 1 to item 2 of dimensions (fArray)
  1019.         set temp to farray[a][i]
  1020.         set farray[a][i] to farray[b][i]
  1021.         set farray[b][i] to temp
  1022. to handle helpTemplate
  1023.     mydir = name of self
  1024.         clear last char of mydir
  1025.     until last char of mydir is "\" or mydir is null
  1026.     sen = sysErrorNumber
  1027.     se = sysError
  1028.     sysErrorNumber = 0
  1029.     ss = sysSuspend
  1030.     syssuspend = false
  1031.     bref = book (mydir&"tmplhelp.tbk")
  1032.     syssuspend = ss
  1033.     if sysErrorNumber is not 0
  1034.         request "Cannot find book TMPLHELP.TBK"
  1035.     else
  1036.         vref = viewer "help" of bref
  1037.         set defaultpage of vref to page "cbt4" of bref
  1038.         open vref
  1039.         show vref
  1040.     sysErrorNumber = sen
  1041.     sysError = se
  1042. CBT1.TBK
  1043. --   Copyright 
  1044.  1994  Asymetrix Corporation                      
  1045. --                                                                     
  1046. --   Asymetrix gives you permission to copy, revise, and reuse the     
  1047. --   individual objects and scripts in this application in your own    
  1048. --   applications.  You may not copy the entire book (or a             
  1049. --   substantial part of it) for redistribution as your own product.   
  1050. --                                                                     
  1051. --   Asymetrix retains the copyright on the original elements of this   
  1052. --   application. Include the notice "Portions of this application are 
  1053. --   the copyright of Asymetrix Corporation" in your product if they   
  1054. --   contain objects or scripts copied from this application.          
  1055. --   Author: Joseph Brick                                              
  1056. --   Last revision: 5/9/94
  1057. --============== Standard ToolBook messages ===================
  1058. -- set up the menus, initialize Back handling
  1059. to handle enterApplication
  1060.     forward
  1061.     set enabled of button "back" of page "toolbar" to false
  1062.     if sysRuntime is false
  1063.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  1064.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  1065.          "Displays/hides Template Outline palette."
  1066.         add menuitem "" to menu "contents" at author
  1067.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  1068.          "Adds new chapter to this book."
  1069.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  1070.          "Changes name of current chapter."
  1071.         add menuitem "" to menu "contents" at author
  1072.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  1073.          "Adds new topic to this chapter."
  1074.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  1075.          "Changes name of topic chapter."
  1076.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  1077.          "Displays help on using this template."
  1078.         if firstTime of this book is not false
  1079.             open viewer "outline"
  1080.             send rebuildStructure
  1081.             firstTime of this book = false
  1082.         end
  1083.     hide button "help" of page "toolbar"
  1084.     -- initialize checkmarks
  1085.     bk = topicsBackground()
  1086.     step i from 1 to pagecount of bk
  1087.         set visited of page i of bk to false
  1088.     set checked of group "tableofcontents" of page "tableOfContents" to false
  1089.     if syslevel is author
  1090.         send reader
  1091. to handle entermenu menuName,menuAlias
  1092.     if menuName is "contents" and syslevel is author
  1093.         if this background is chaptersBackground() 
  1094.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  1095.         else
  1096.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  1097.         end
  1098.         if this background is TopicsBackground() 
  1099.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  1100.         else
  1101.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  1102.         end
  1103.         if visible of viewer "outline"
  1104.             check menuitem "outline"  in menu "contents" at author
  1105.         else
  1106.             uncheck menuitem "outline"  in menu "contents" at author
  1107.         end
  1108.     forward
  1109. to handle leaveapplication
  1110.     remove menu "Contents" at author
  1111.     remove menuitem "helpTemplate" in menu "help" at author
  1112.     forward
  1113. to handle author
  1114.     if isOpen of viewer "outline"
  1115.         set fw to focusWindow
  1116.         show viewer "outline"
  1117.         set focusWindow to fw
  1118.     show button "help" of page "toolbar"
  1119.     forward
  1120. to handle reader
  1121.     forward
  1122.     if isOpen of viewer "outline"
  1123.         hide viewer "outline"
  1124.     hide button "help" of page "toolbar"
  1125. to handle outline
  1126.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  1127.     if mstate is true
  1128.         if isOpen of viewer "outline"
  1129.             close viewer "outline"
  1130.         end
  1131.     else
  1132.         open viewer "outline"
  1133.         send rebuildStructure
  1134.         show viewer "outline"
  1135. -- if a newbackground is inserted into the content area,
  1136. -- move it beyond the content area
  1137. to handle newBackground
  1138.     forward
  1139.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  1140.                    pagenumber of last page of topicsBackground())
  1141.     if pagenumber of this page < lastPage
  1142.         pageNumber of this page = lastPage
  1143. --================ Utility handlers ===================
  1144. -- returns the background reference for the chapter headings background
  1145. to get chaptersBackground
  1146.     return background "chapter headings"
  1147. -- returns the background reference for the chapter topics background
  1148. to get topicsBackground
  1149.     return background "topics"
  1150. to handle rebuildStructure updatePalette
  1151.     if updatePalette is null
  1152.         updatePalette = true
  1153.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  1154.     pageNumber of page "tableofcontents" = 1
  1155.     pagenumber of first page of chaptersBackground() = 2
  1156.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  1157.                    pagenumber of last page of topicsBackground())
  1158.     pageCounter = 2
  1159.     while pageCounter <= lastPage
  1160.         curPage = page pageCounter
  1161.         curPageId = idnumber of curPage
  1162.         curBackground = parent of curPage
  1163.         pagelabel = label of curPage
  1164.         conditions
  1165.             when curBackground is chaptersBackground()
  1166.                 if prevChapterHeadingPage is not NULL
  1167.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  1168.                     clear pagesOfEachChapter
  1169.                 end
  1170.                 prevChapterHeadingPage = curPage
  1171.                 curChapterId = curPageId
  1172.                 myChapterID of curPage = curChapterID
  1173.                 if chapterList is not null
  1174.                     put crlf after chapterList
  1175.                 end
  1176.                 put curPageId & "," & pageLabel after chapterList
  1177.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  1178.                 increment pageCounter
  1179.             when curBackground is topicsBackground()
  1180.                 if pagesOfEachChapter is not null
  1181.                     put "," after pagesOfEachChapter
  1182.                 end
  1183.                 put idnumber of curPage after pagesOfEachChapter
  1184.                 myChapterID of curPage = curChapterID
  1185.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  1186.                 increment pageCounter
  1187.         else
  1188.             -- this page is not of either background. Move it beyond both backgrounds
  1189.             pageNumber of curPage = lastPage
  1190.             decrement lastPage    
  1191.         end
  1192.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  1193.     voutline of group "tableOfContents" of page "tableOfContents" = chapterList
  1194.     clear last char of listBoxText
  1195.     clear last char of listBoxText
  1196.     if updatePalette
  1197.         if isOpen of viewer "outline"
  1198.             send initPage listBoxText to currentPage of viewer "outline"
  1199.         end
  1200.     in mainWindow
  1201.         send initPage to this page
  1202. -- Used to get the text before a tab of a textline
  1203. -- (in the list box of a dialog viewer, tab is used 
  1204. -- to store extra information that gets clipped by the 
  1205. -- right side of the field)
  1206. to get extractName t
  1207.     if first char of t is tab
  1208.         clear first char of t
  1209.     tabOffset = offset(tab,t)
  1210.     if tabOffset is 0
  1211.         return null
  1212.     else
  1213.         return chars 1 to tabOffset-1 of t
  1214. -- Used to get the text beyond a tab of a textline
  1215. to get extractID t
  1216.     lastTabLoc = charcount(t)
  1217.         decrement lastTabLoc
  1218.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  1219.     if lastTabLoc <=0
  1220.         return null
  1221.     else
  1222.         return chars lastTabLoc+1 to charcount(t) of t
  1223. -- returns the numerical location of an item in a list
  1224. to get itemOffset itm,lst
  1225.     step i from 1 to itemcount(lst)
  1226.         pop lst
  1227.         if it = itm
  1228.             return i
  1229.         end
  1230.     return 0
  1231. -- returns a gray color
  1232. to get middleGray
  1233.     return 240,63.5,2.1875
  1234. -- returns dark blue
  1235. to get darkBlue
  1236.     return 240,25.125,100
  1237. -- returns a string of tabs. This serves a spacer between the 
  1238. -- label of a page and the idnumber on each line in the listbox. 
  1239. -- This is used so the idnumber is clipped and not visible
  1240. to get tabSpacer
  1241.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  1242. --============= Navigation and menu messages =============
  1243. -- tableOfContents message sent by toolbar
  1244. -- when the tableOfContents button is pressed
  1245. to handle tableOfContents
  1246.     pref = page "tableOfContents"
  1247.     send updatechecks to group "tableofcontents" of pref
  1248.     go to pref
  1249. to handle helpTemplate
  1250.     mydir = name of self
  1251.         clear last char of mydir
  1252.     until last char of mydir is "\" or mydir is null
  1253.     sen = sysErrorNumber
  1254.     se = sysError
  1255.     sysErrorNumber = 0
  1256.     ss = sysSuspend
  1257.     syssuspend = false
  1258.     bref = book (mydir&"tmplhelp.tbk")
  1259.     syssuspend = ss
  1260.     if sysErrorNumber is not 0
  1261.         request "Cannot find book TMPLHELP.TBK"
  1262.     else
  1263.         vref = viewer "help" of bref
  1264.         set defaultpage of vref to page "cbt1" of bref
  1265.         open vref
  1266.         show vref
  1267.     sysErrorNumber = sen
  1268.     sysError = se
  1269. to handle initPage
  1270. to handle newChapter promptForName
  1271.     if promptForName is null
  1272.         promptForName = true
  1273.     chapterName = "Untitled"
  1274.     if promptForName
  1275.         ask "Enter new chapter name." with chapterName
  1276.         if syserror = cancel
  1277.             break
  1278.         end
  1279.         chapterName = it
  1280.     in mainwindow
  1281.         ls = lockscreen of this window
  1282.         lockscreen of this window = true
  1283.         go to last page of chaptersBackground()
  1284.         ssm = syssuspendmessages
  1285.         syssuspendmessages = true
  1286.         send newPage
  1287.         syssuspendmessages = ssm
  1288.         set label of this page to chapterName
  1289.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  1290.                        pagenumber of last page of topicsBackground())
  1291.         set pageNumber of this page to lastPage
  1292.         send rebuildStructure
  1293.         send enterPage to this page
  1294.         lockscreen of this window = ls
  1295. to handle newTopic pageNum
  1296.     chapterName = "Untitled"
  1297.     if pageNum is null
  1298.         ask "Enter new topic name." with chapterName
  1299.         if syserror = cancel
  1300.             break
  1301.         end
  1302.         chapterName = it
  1303.     in mainWindow
  1304.         if pageNum is null
  1305.             conditions
  1306.                 when this background is chaptersBackground()
  1307.                 when this background is topicsBackground()
  1308.                     pageNum = pageNumber of this page
  1309.             else
  1310.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  1311.                                pagenumber of last page of topicsBackground())
  1312.                 pageNum = lastPage
  1313.             end
  1314.         end
  1315.         ls = lockscreen of this window
  1316.         lockscreen of this window = true
  1317.         if this background is not topicsBackground()
  1318.             go to last page of topicsBackground()
  1319.         end
  1320.         ssm = syssuspendmessages
  1321.         syssuspendmessages = true
  1322.         send newPage
  1323.         syssuspendmessages = ssm
  1324.         set label of this page to chapterName
  1325.         set pageNumber of this page to pageNum+1
  1326.         send rebuildStructure
  1327.         send enterPage to this page
  1328.         lockscreen of this window = ls
  1329. to handle changeName
  1330.     ask "Enter new name." with label of this page
  1331.     if syserror = cancel
  1332.         break
  1333.     label of this page = it
  1334.     send rebuildStructure
  1335. CBT2.TBK
  1336. --   Copyright 
  1337.  1994  Asymetrix Corporation                      
  1338. --                                                                     
  1339. --   Asymetrix gives you permission to copy, revise, and reuse the     
  1340. --   individual objects and scripts in this application in your own    
  1341. --   applications.  You may not copy the entire book (or a             
  1342. --   substantial part of it) for redistribution as your own product.   
  1343. --                                                                     
  1344. --   Asymetrix retains the copyright on the original elements of this   
  1345. --   application. Include the notice "Portions of this application are 
  1346. --   the copyright of Asymetrix Corporation" in your product if they   
  1347. --   contain objects or scripts copied from this application.          
  1348. --   Author: Joseph Brick                                              
  1349. --   Last revision: 5/9/94
  1350. to handle enterApplication
  1351.     forward
  1352.     go to page "introscreen"
  1353.     if sysRuntime is false
  1354.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  1355.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  1356.          "Displays/hides Template Outline palette."
  1357.         add menuitem "" to menu "contents" at author
  1358.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  1359.          "Adds new chapter to this book."
  1360.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  1361.          "Changes name of current chapter."
  1362.         add menuitem "" to menu "contents" at author
  1363.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  1364.          "Adds new topic to this chapter."
  1365.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  1366.          "Changes name of topic chapter."
  1367.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  1368.          "Displays help on using this template."
  1369.         if firstTime of this book is not false
  1370.             open viewer "outline"
  1371.             send rebuildStructure
  1372.             firstTime of this book = false
  1373.         end
  1374.     send reader
  1375. to handle entermenu menuName,menuAlias
  1376.     if menuName is "contents" and syslevel is author
  1377.         if this background is chaptersBackground() 
  1378.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  1379.         else
  1380.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  1381.         end
  1382.         if this background is TopicsBackground() 
  1383.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  1384.         else
  1385.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  1386.         end
  1387.         if visible of viewer "outline"
  1388.             check menuitem "outline"  in menu "contents" at author
  1389.         else
  1390.             uncheck menuitem "outline"  in menu "contents" at author
  1391.         end
  1392.     forward
  1393. to handle leaveapplication
  1394.     remove menu "Contents" at author
  1395.     remove menuitem "helpTemplate" in menu "help" at author
  1396.     forward
  1397. to handle author
  1398.     if isOpen of viewer "outline"
  1399.         set fw to focusWindow
  1400.         show viewer "outline"
  1401.         set focusWindow to fw
  1402.     set state of mainwindow to normal
  1403.     set captionBar of mainwindow to normal
  1404.     forward
  1405. to handle reader
  1406.     forward
  1407.     if isOpen of viewer "outline"
  1408.         hide viewer "outline"
  1409.     set captionBar of mainwindow to none
  1410.     set state of mainwindow to maximized
  1411. to handle outline
  1412.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  1413.     if mstate is true
  1414.         if isOpen of viewer "outline"
  1415.             close viewer "outline"
  1416.         end
  1417.     else
  1418.         open viewer "outline"
  1419.         send rebuildStructure
  1420.         show viewer "outline"
  1421. -- if a newbackground is inserted into the content area,
  1422. -- move it beyond the content area
  1423. to handle newBackground
  1424.     forward
  1425.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  1426.                    pagenumber of last page of topicsBackground())
  1427.     if pagenumber of this page < lastPage
  1428.         pageNumber of this page = lastPage
  1429. --================ Utility handlers ===================
  1430. -- returns the background reference for the chapter headings background
  1431. to get chaptersBackground
  1432.     return background "chapterheadings"
  1433. -- returns the background reference for the chapter topics background
  1434. to get topicsBackground
  1435.     return background "content"
  1436. to handle rebuildStructure updatePalette
  1437.     local chapterCounter
  1438.     chapterCounter = 0
  1439.     if updatePalette is null
  1440.         updatePalette = true
  1441.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  1442.     pageNumber of page "introscreen" = 1
  1443.     pagenumber of first page of chaptersBackground() = 2
  1444.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  1445.                    pagenumber of last page of topicsBackground())
  1446.     pageCounter = 2
  1447.     while pageCounter <= lastPage
  1448.         curPage = page pageCounter
  1449.         curPageId = idnumber of curPage
  1450.         curBackground = parent of curPage
  1451.         pagelabel = label of curPage
  1452.         conditions
  1453.             when curBackground is chaptersBackground()
  1454.                 increment chapterCounter
  1455.                 if prevChapterHeadingPage is not NULL
  1456.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  1457.                     clear pagesOfEachChapter
  1458.                 end
  1459.                 prevChapterHeadingPage = curPage
  1460.                 curChapterId = curPageId
  1461.                 myChapterID of curPage = curChapterID
  1462.                 if chapterList is not null
  1463.                     put crlf after chapterList
  1464.                 end
  1465.                 put curPageId & "," & pageLabel after chapterList
  1466.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  1467.                 increment pageCounter
  1468.             when curBackground is topicsBackground()
  1469.                 chapter of curPage = chapterCounter
  1470.                 if pagesOfEachChapter is not null
  1471.                     put "," after pagesOfEachChapter
  1472.                 end
  1473.                 put idnumber of curPage after pagesOfEachChapter
  1474.                 myChapterID of curPage = curChapterID
  1475.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  1476.                 increment pageCounter
  1477.         else
  1478.             -- this page is not of either background. Move it beyond both backgrounds
  1479.             pageNumber of curPage = lastPage
  1480.             decrement lastPage    
  1481.         end
  1482.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  1483.     voutline of group "tableOfContents" of background "Content" = chapterList
  1484.     clear last char of listBoxText
  1485.     clear last char of listBoxText
  1486.     if updatePalette
  1487.         if isOpen of viewer "outline"
  1488.             send initPage listBoxText to currentPage of viewer "outline"
  1489.             in mainWindow
  1490.                 send enterpage to this page
  1491.             end
  1492.         end
  1493. -- Used to get the text before a tab of a textline
  1494. -- (in the list box of a dialog viewer, tab is used 
  1495. -- to store extra information that gets clipped by the 
  1496. -- right side of the field)
  1497. to get extractName t
  1498.     if first char of t is tab
  1499.         clear first char of t
  1500.     tabOffset = offset(tab,t)
  1501.     if tabOffset is 0
  1502.         return null
  1503.     else
  1504.         return chars 1 to tabOffset-1 of t
  1505. -- Used to get the text beyond a tab of a textline
  1506. to get extractID t
  1507.     lastTabLoc = charcount(t)
  1508.         decrement lastTabLoc
  1509.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  1510.     if lastTabLoc <=0
  1511.         return null
  1512.     else
  1513.         return chars lastTabLoc+1 to charcount(t) of t
  1514. -- returns the numerical location of an item in a list
  1515. to get itemOffset itm,lst
  1516.     step i from 1 to itemcount(lst)
  1517.         pop lst
  1518.         if it = itm
  1519.             return i
  1520.         end
  1521.     return 0
  1522. -- returns a gray color
  1523. to get middleGray
  1524.     return 240,63.5,2.1875
  1525. -- returns dark blue
  1526. to get darkBlue
  1527.     return 240,25.125,100
  1528. -- returns a string of tabs. This serves a spacer between the 
  1529. -- label of a page and the idnumber on each line in the listbox. 
  1530. -- This is used so the idnumber is clipped and not visible
  1531. to get tabSpacer
  1532.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  1533. to handle helpTemplate
  1534.     mydir = name of self
  1535.         clear last char of mydir
  1536.     until last char of mydir is "\" or mydir is null
  1537.     sen = sysErrorNumber
  1538.     se = sysError
  1539.     sysErrorNumber = 0
  1540.     ss = sysSuspend
  1541.     syssuspend = false
  1542.     bref = book (mydir&"tmplhelp.tbk")
  1543.     syssuspend = ss
  1544.     if sysErrorNumber is not 0
  1545.         request "Cannot find book TMPLHELP.TBK"
  1546.     else
  1547.         vref = viewer "help" of bref
  1548.         set defaultpage of vref to page "cbt1" of bref
  1549.         open vref
  1550.         show vref
  1551.     sysErrorNumber = sen
  1552.     sysError = se
  1553. to handle initPage
  1554. to handle newChapter promptForName
  1555.     if promptForName is null
  1556.         promptForName = true
  1557.     chapterName = "Untitled"
  1558.     if promptForName
  1559.         ask "Enter new chapter name." with chapterName
  1560.         if syserror = cancel
  1561.             break
  1562.         end
  1563.         chapterName = it
  1564.     in mainwindow
  1565.         ls = lockscreen of this window
  1566.         lockscreen of this window = true
  1567.         go to last page of chaptersBackground()
  1568.         ssm = syssuspendmessages
  1569.         syssuspendmessages = true
  1570.         send newPage
  1571.         syssuspendmessages = ssm
  1572.         set label of this page to chapterName
  1573.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  1574.                        pagenumber of last page of topicsBackground())
  1575.         set pageNumber of this page to lastPage
  1576.         send rebuildStructure
  1577.         send enterPage to this page
  1578.         lockscreen of this window = ls
  1579. to handle newTopic pageNum
  1580.     chapterName = "Untitled"
  1581.     if pageNum is null
  1582.         ask "Enter new topic name." with chapterName
  1583.         if syserror = cancel
  1584.             break
  1585.         end
  1586.         chapterName = it
  1587.     in mainWindow
  1588.         if pageNum is null
  1589.             conditions
  1590.                 when this background is chaptersBackground()
  1591.                 when this background is topicsBackground()
  1592.                     pageNum = pageNumber of this page
  1593.             else
  1594.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  1595.                                pagenumber of last page of topicsBackground())
  1596.                 pageNum = lastPage
  1597.             end
  1598.         end
  1599.         ls = lockscreen of this window
  1600.         lockscreen of this window = true
  1601.         if this background is not topicsBackground()
  1602.             go to last page of topicsBackground()
  1603.         end
  1604.         ssm = syssuspendmessages
  1605.         syssuspendmessages = true
  1606.         send newPage
  1607.         syssuspendmessages = ssm
  1608.         set label of this page to chapterName
  1609.         set pageNumber of this page to pageNum+1
  1610.         send rebuildStructure
  1611.         send enterPage to this page
  1612.         lockscreen of this window = ls
  1613. to handle changeName
  1614.     ask "Enter new name." with label of this page
  1615.     if syserror = cancel
  1616.         break
  1617.     label of this page = it
  1618.     send rebuildStructure
  1619. to handle sizeToPage
  1620.     if syslevel is AUTHOR
  1621.         forward
  1622. to handle exit
  1623.     syserror = null
  1624.     forward
  1625.     if syserror is null
  1626.         set syslockscreen to true
  1627.         set captionBar of mainwindow to normal
  1628.         set state of mainwindow to normal
  1629. CBT3.TBK
  1630. --   Copyright 
  1631.  1994  Asymetrix Corporation                      
  1632. --                                                                     
  1633. --   Asymetrix gives you permission to copy, revise, and reuse the     
  1634. --   individual objects and scripts in this application in your own    
  1635. --   applications.  You may not copy the entire book (or a             
  1636. --   substantial part of it) for redistribution as your own product.   
  1637. --                                                                     
  1638. --   Asymetrix retains the copyright on the original elements of this   
  1639. --   application. Include the notice "Portions of this application are 
  1640. --   the copyright of Asymetrix Corporation" in your product if they   
  1641. --   contain objects or scripts copied from this application.          
  1642. --   Author: Joseph Brick                                              
  1643. --   Last revision: 5/9/94
  1644. to handle enterMenu menuName,alias
  1645.     -- if menu "Page" is selected
  1646.     if syslevel is reader and menuName is "Page"
  1647.         -- set all menus to known state
  1648.         enable menuitem "Next" in menu menuName at reader
  1649.         enable menuitem "Previous" in menu menuName at reader
  1650.         enable menuitem "First" in menu menuName at reader
  1651.         enable menuitem "Last" in menu menuName at reader
  1652.         if isOpen of viewer "scroll"
  1653.             in viewer "scroll"
  1654.                 -- disable "First" and "Previous", if appropriate
  1655.                 if this page is first page of this background
  1656.                     in mainWindow
  1657.                         disable menuitem "First" in menu menuName at reader
  1658.                         disable menuitem "Previous" in menu menuName at reader
  1659.                     end
  1660.                 end
  1661.                 -- disable "Last" and "Next", if appropriate
  1662.                 if this page is last page of this background
  1663.                     in mainWindow
  1664.                         disable menuitem "Last" in menu menuName at reader
  1665.                         disable menuitem "Next" in menu menuName at reader
  1666.                     end
  1667.                 end
  1668.             end
  1669.         end
  1670.     forward
  1671. to handle enterApplication
  1672.     forward
  1673.     if syslevel is not reader
  1674.         syslevel = reader
  1675. to handle aboutTemplate
  1676.     mydir = name of self
  1677.         clear last char of mydir
  1678.     until last char of mydir is "\" or mydir is null
  1679.     sen = sysErrorNumber
  1680.     se = sysError
  1681.     sysErrorNumber = 0
  1682.     ss = sysSuspend
  1683.     syssuspend = false
  1684.     bref = book (mydir&"tmplhelp.tbk")
  1685.     syssuspend = ss
  1686.     if sysErrorNumber is not 0
  1687.         request "Cannot find book TMPLHELP.TBK"
  1688.     else
  1689.         vref = viewer "help" of bref
  1690.         set defaultpage of vref to page "cbt3" of bref
  1691.         open vref
  1692.         show vref
  1693.     sysErrorNumber = sen
  1694.     sysError = se
  1695. CBT3.TBK
  1696. --   Copyright 
  1697.  1994  Asymetrix Corporation                      
  1698. --                                                                     
  1699. --   Asymetrix gives you permission to copy, revise, and reuse the     
  1700. --   individual objects and scripts in this application in your own    
  1701. --   applications.  You may not copy the entire book (or a             
  1702. --   substantial part of it) for redistribution as your own product.   
  1703. --                                                                     
  1704. --   Asymetrix retains the copyright on the original elements of this   
  1705. --   application. Include the notice "Portions of this application are 
  1706. --   the copyright of Asymetrix Corporation" in your product if they   
  1707. --   contain objects or scripts copied from this application.          
  1708. --   Author: Joseph Brick                                              
  1709. --   Last revision: 5/9/94
  1710. to handle enterMenu menuName,alias
  1711.     -- if menu "Page" is selected
  1712.     if syslevel is reader and menuName is "Page"
  1713.         -- set all menus to known state
  1714.         enable menuitem "Next" in menu menuName at reader
  1715.         enable menuitem "Previous" in menu menuName at reader
  1716.         enable menuitem "First" in menu menuName at reader
  1717.         enable menuitem "Last" in menu menuName at reader
  1718.         if isOpen of viewer "scroll"
  1719.             in viewer "scroll"
  1720.                 -- disable "First" and "Previous", if appropriate
  1721.                 if this page is first page of this background
  1722.                     in mainWindow
  1723.                         disable menuitem "First" in menu menuName at reader
  1724.                         disable menuitem "Previous" in menu menuName at reader
  1725.                     end
  1726.                 end
  1727.                 -- disable "Last" and "Next", if appropriate
  1728.                 if this page is last page of this background
  1729.                     in mainWindow
  1730.                         disable menuitem "Last" in menu menuName at reader
  1731.                         disable menuitem "Next" in menu menuName at reader
  1732.                     end
  1733.                 end
  1734.             end
  1735.         end
  1736.     forward
  1737. to handle enterApplication
  1738.     forward
  1739.     if syslevel is not reader
  1740.         syslevel = reader
  1741. to handle aboutTemplate
  1742.     mydir = name of self
  1743.         clear last char of mydir
  1744.     until last char of mydir is "\" or mydir is null
  1745.     sen = sysErrorNumber
  1746.     se = sysError
  1747.     sysErrorNumber = 0
  1748.     ss = sysSuspend
  1749.     syssuspend = false
  1750.     bref = book (mydir&"tmplhelp.tbk")
  1751.     syssuspend = ss
  1752.     if sysErrorNumber is not 0
  1753.         request "Cannot find book TMPLHELP.TBK"
  1754.     else
  1755.         vref = viewer "help" of bref
  1756.         set defaultpage of vref to page "cbt3" of bref
  1757.         open vref
  1758.         show vref
  1759.     sysErrorNumber = sen
  1760.     sysError = se
  1761.     local x[][]
  1762.         set x to categoryStruct of this book
  1763.         set pageID to idnumber of target
  1764.         step i from 1 to item 1 of dimensions(x)
  1765.             get itemOffset(pageID,x[i][2])
  1766.             if it > 0
  1767.                 clear item it of x[i][2]
  1768.             end
  1769.         end
  1770.         set categoryStruct of this book to x
  1771.     forward
  1772. to handle enterPage
  1773.     forward
  1774.     -- if this is a content background
  1775.     if name of parent of this page is in "description and script,description and example,description only"
  1776.         -- to ensure the recordfield is set to the label property
  1777.         -- the label property holds the name of each topic
  1778.         set fref to recordfield "subTopicName" of this page
  1779.         if text of fref is not label of this page
  1780.             set text of fref to label of this page
  1781.         end
  1782.         -- set the scroll of the recordfield, if necessary
  1783.         set fref to recordfield "explanation"
  1784.         if scroll of fref is not 0
  1785.             set scroll of fref to 0
  1786.         end
  1787.         -- add/remove scrollbars, if necessary
  1788.         set txtOver to textoverflow of fref
  1789.         conditions
  1790.             when txtOver > 0 and borderstyle of fref is "none"
  1791.                 set borderstyle of fref to "scrolling"
  1792.             when txtOver = 0 and borderstyle of fref is "scrolling"
  1793.                 set borderstyle of fref to "none"
  1794.         end
  1795. to handle leavePage
  1796.     forward
  1797.     if name of parent of this page is in "description and script,description and example,description only"
  1798.         set topic to text of recordfield "subTopicName"
  1799.         if label of this page is not topic
  1800.             set label of this page to topic
  1801.         end
  1802. --========================= Utility handlers ===========================
  1803. -- returns the text before a tab
  1804. to get extractName t
  1805.     set tabOffset to offset(tab,t)
  1806.     return chars 1 to tabOffset-1 of t
  1807. -- returns the text following a tab
  1808. to get extractID t
  1809.     set lastTabLoc to charcount(t)
  1810.         decrement lastTabLoc
  1811.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  1812.     if lastTabLoc <=0
  1813.         return null
  1814.     else
  1815.         return chars lastTabLoc+1 to charcount(t) of t
  1816. -- returns the offset of item itm in list lst
  1817. to get itemOffset itm,lst
  1818.     step i from 1 to itemcount(lst)
  1819.         pop lst
  1820.         if itm = it
  1821.             return i
  1822.         end
  1823.     return 0
  1824. -- removes all instances of a char from a string
  1825. to get stripChar chr,strng
  1826.     while strng contains chr
  1827.         clear char offset(chr,strng) of strng
  1828.     return strng
  1829. -- returns the number of colors displayed
  1830. to get numColors
  1831.     hdc = getDC(windowhandle of mainWindow)
  1832.     retval = getDeviceCaps(hdc,24)
  1833.     get releaseDC(windowhandle of mainwindow,hdc)
  1834.     return retval
  1835. to get darkerBlue
  1836.     return 212,79.1875,71.6875
  1837. to get lighterBlue
  1838.     return 180,75.125,100
  1839. to set backColor to value
  1840.     set bckgrnds to "intro,description and script,description and example,description only"
  1841.     step i from 1 to itemcount(bckgrnds)
  1842.         pop bckgrnds
  1843.         set curBack to background it
  1844.         if fillcolor of curBack is not value
  1845.             set fillcolor of curBack to value
  1846.         end
  1847. --================ Handlers for dealing with array structure ============
  1848. -- display the array in a request box.
  1849. -- (used during authoring for debugging purposes)
  1850. to handle showCategoryStruct
  1851.     local x[][]
  1852.     set x to categoryStruct of this book
  1853.     local retval
  1854.     step i from 1 to item 1 of dimensions(x)
  1855.         put x[i][1] after retval
  1856.         put tab & x[i][2] & crlf after retval
  1857.     request retval
  1858. --------------- these handers sort the array --------------------
  1859. to handle twoDquicksort fArray[][],n,dtype
  1860.     system stbk_noSwap
  1861.     set stbk_noSwap to 0
  1862.     send twoDquicksrt fArray, 1, item 1 of dimensions(fArray),n,dtype
  1863. to handle twoDquicksrt fArray[][], l, r,n,dtype
  1864.     system  stbk_noSwap
  1865.     if r > l 
  1866.         send swap  fArray, l, ((l+r) div 2)
  1867.         set lst to l
  1868.         step i from (l+1) to r
  1869.             conditions
  1870.                 when dtype is "text"
  1871.                     set test to fArray[i][n] < fArray[l][n] as text
  1872.                 when dtype is "date"
  1873.                     set test to fArray[i][n] < fArray[l][n] as date
  1874.                 else
  1875.                     set test to fArray[i][n] < fArray[l][n] as number
  1876.             end
  1877.             if test
  1878.                 increment lst
  1879.                 send swap fArray, lst, i
  1880.             else
  1881.                 increment stbk_noswap
  1882.             end if
  1883.         end step
  1884.         send swap fArray,l,lst 
  1885.            
  1886.            send twoDquicksrt fArray, l, lst-1,n,dtype
  1887.         send twoDquicksrt fArray, lst+1,r,n,dtype
  1888.        end
  1889. to handle swap fArray[][], a, b
  1890.     local temp
  1891.     step i from 1 to item 2 of dimensions (fArray)
  1892.         set temp to farray[a][i]
  1893.         set farray[a][i] to farray[b][i]
  1894.         set farray[b][i] to temp
  1895. to handle helpTemplate
  1896.     mydir = name of self
  1897.         clear last char of mydir
  1898.     until last char of mydir is "\" or mydir is null
  1899.     sen = sysErrorNumber
  1900.     se = sysError
  1901.     sysErrorNumber = 0
  1902.     ss = sysSuspend
  1903.     syssuspend = false
  1904.     bref = book (mydir&"tmplhelp.tbk")
  1905.     syssuspend = ss
  1906.     if sysErrorNumber is not 0
  1907.         request "Cannot find book TMPLHELP.TBK"
  1908.     else
  1909.         vref = viewer "help" of bref
  1910.         set defaultpage of vref to page "cbt4" of bref
  1911.         open vref
  1912.         show vref
  1913.     sysErrorNumber = sen
  1914.     sysError = se
  1915. CONTACT.TBK
  1916. T--***************************************************************************
  1917. --                      Asymetrix Contact: dBase sample app.
  1918. --                             
  1919. --                        Asymetrix Corporation 1994
  1920. -- Authored by Charles Hiestand & Jeff Ayars
  1921. -- Copyright 
  1922.  1994  Asymetrix Corporation
  1923. -- Asymetrix gives you permission to copy, revise and reuse the individual 
  1924. -- objects and scripts in this application in your own applications.  
  1925. -- You may not, however, copy the entire book (or a substantial part of it) 
  1926. -- for redistribution as your own product.
  1927. -- Asymetrix retains the copyright on the original elements of this 
  1928. -- application. Include the notice "Portions of this application are the 
  1929. -- copyright of Asymetrix Corporation" in your product if they contain 
  1930. -- objects or scripts copied from this application.
  1931. -- A note on language independence:  For ease of translating this 
  1932. -- application, all text strings visible to readers that come from scripts 
  1933. -- are put into functions located at the bottom of this book script.  
  1934. --*******************************************************************************
  1935. --************************ Handlers for built in messages ***************************
  1936. -- initialize the path, the text fields, link TB30DB3.DLL, open the dBase files
  1937. to handle enterApplication
  1938.     system s_bookPath
  1939.     system LOGICAL s_firstFlag
  1940.     sysLevel = reader
  1941.     sysCursor = none
  1942.     sysLockScreen = TRUE
  1943.     s_firstFlag = TRUE
  1944.     s_bookPath = name of this book
  1945.     while last character of s_bookPath <> "\"
  1946.         clear last character of s_bookPath
  1947.     end while
  1948.     send linkDB3
  1949.     set sysCursor to default
  1950.     get OpenDBFile(s_bookPath & "contact.dbf")
  1951.     if it < 0
  1952.         request stringOpenError("contact.dbf")
  1953.     else
  1954.         index of this book = "name.ndx"
  1955.         checked of button "name" = TRUE
  1956.         selectedTextlines of field "records" = 1
  1957.         focus = field "records"
  1958.         send updateRecords to field "records"
  1959.     end if
  1960.     -- Make sure book is initialized to browse mode
  1961.     if caption of button "edit" of page 1 = stringResource("Browse")
  1962.         send buttonClick to button "edit" of page 1
  1963.     end if
  1964.     sysLockScreen = FALSE
  1965.     show mainWindow
  1966.     show viewer "splash"
  1967.     forward
  1968.     pause 2 seconds
  1969.     close viewer "splash"
  1970. end enterApplication
  1971. to handle leaveApplication
  1972.     get closeAllDBFiles()
  1973.     unlinkDLL sysToolBookDirectory & "TB30DB3"
  1974.     forward
  1975. end leaveApplication
  1976. to handle idle
  1977. -- we make doubly sure that the window sizes correctly
  1978.     system s_firstFlag
  1979.     forward
  1980.     if s_firstFlag is TRUE
  1981.         clear s_firstFlag
  1982.         send sizeToPage
  1983.     end if
  1984. end idle
  1985. -- Handles all the help messages in the status bar.
  1986. -- The property "helpText" is either a keyword or null for every object in
  1987. -- the book. StringHelp uses the keyword to return the displayed text.
  1988. to handle mouseEnter
  1989.     caption of statusBar = stringHelp(helpText of target)
  1990. end mouseEnter
  1991. to handle mouseLeave
  1992.     caption of statusBar = " "
  1993. end mouseLeave    
  1994. to handle enterMenu mName,mAlias
  1995.     if mName = "File"
  1996.         enable menuItem "printReport"
  1997.     end if
  1998.     forward
  1999. end enterMenu
  2000. -- "About", just the splash screen.
  2001. to handle about
  2002.     show viewer "splash" as modal
  2003. end about
  2004. -- "Quick Help"
  2005. to handle quickHelp
  2006.     show viewer "Quick Help" as modal
  2007. end quickHelp
  2008. -- Simple save handler
  2009. -- More for creating and debugging
  2010. to handle save
  2011.     forward
  2012.     send updateDB    
  2013. end save
  2014. -- These prevent resizing problems in 640 X 480 mode.
  2015. -- In higher modes, it may look better to not have these handlers.
  2016. to handle reader
  2017.     forward
  2018.     send sizeToPage
  2019. end reader
  2020. to handle author
  2021.     forward
  2022.     send sizeToPage
  2023. end author
  2024. --*******************************************************************************
  2025. --*********************** Handlers for custom messages **************************
  2026. -- Links all the functions, but not all functions are used
  2027. to handle linkDB3
  2028.     clear sysError
  2029.     sysSuspend = false -- we'll handle our own errors if linking fails
  2030.     clear sysError
  2031.     linkdll sysToolBookDirectory & "TB30DB3.DLL"
  2032.         INT checkDBIndex(STRING)
  2033.         INT closeAllDBFiles()
  2034.         INT closeDBFile(STRING)
  2035.         INT closeDBIndexFile(STRING)
  2036.         WORD createDBFieldTag(WORD)
  2037.         INT createDBFile(STRING,WORD,WORD)
  2038.         INT createDBIndexFile(STRING,STRING,WORD,WORD)
  2039.         INT deleteDBFile(STRING)
  2040.         INT deselectDBIndexFile()
  2041.         INT findDBKey(STRING)
  2042.         INT firstDBKey()
  2043.         INT firstDBRecord()
  2044.         INT freeDBFieldTag(WORD)
  2045.         STRING getDBDateFormat()
  2046.         STRING getDBErrorString(INT)
  2047.         INT getDBFieldCount()
  2048.         STRING getDBFieldName(WORD)
  2049.         INT getDBFieldPrecision(STRING)
  2050.         INT getDBFieldType(STRING)
  2051.         STRING getDBFieldValue(STRING)
  2052.         INT getDBFieldWidth(STRING)
  2053.         STRING getDBFileName()
  2054.         STRING getDBIndexExpression()
  2055.         STRING getDBIndexFileName()
  2056.         INT getDBKeyType()
  2057.         STRING getDBKeyValue()
  2058.         INT getDBNavigateToDeleted()
  2059.         LONG getDBRecordCount()
  2060.         INT getDBRecordDeleted()
  2061.         LONG getDBRecordNumber()
  2062.         INT gotoDBRecord(DWORD)
  2063.         INT lastDBKey()
  2064.         INT lastDBRecord()
  2065.         INT nextDBKey()
  2066.         INT nextDBRecord()
  2067.         INT openDBFile(STRING)
  2068.         INT openDBIndexFile(STRING)
  2069.         INT packDBFile()
  2070.         INT previousDBKey()
  2071.         INT previousDBRecord()
  2072.         INT reindexDBFile(STRING)
  2073.         INT removeDBRecords(DWORD,DWORD)
  2074.         INT selectDBFile(STRING)
  2075.         INT selectDBIndexFile(STRING)
  2076.         INT setDBDateFormat(STRING)
  2077.         INT setDBFieldTag(WORD,WORD,STRING,STRING,WORD,WORD)
  2078.         INT setDBFieldValue(STRING, STRING)
  2079.         INT setDBNavigateToDeleted(INT)
  2080.         INT setDBRecordDeleted(WORD)
  2081.         INT writeDBRecord(DWORD)
  2082.     end linkdll
  2083.     if sysError <> null
  2084.         request stringError("linkError")
  2085.     end if
  2086. end linkDB3
  2087. -- Gets better scrolling behavior for the field "record".
  2088. -- Many of the buttons on the page have notify handlers for this message
  2089. to handle updateDisplay
  2090.     system ARRAY LONG s_recordNumbertoTextline[]
  2091.     oldFocus = focus
  2092.     currentScroll = scroll of field "records"
  2093.     newScroll = s_recordNumbertoTextline[currentRecord of this book]
  2094.     selectedTextlines of field "records" = newScroll
  2095.     -- size of the bottom scroll of the field is hardwired to "6"
  2096.     fieldSize = textLineCount(text of field "records") - 6
  2097.     if newScroll > currentScroll + 6
  2098.         scroll of field "records" = min(fieldSize,newScroll - 1)
  2099.     else
  2100.         if newScroll < currentScroll + 1
  2101.             scroll of field "records" = max(newScroll - 6,0)
  2102.         end
  2103.     end if
  2104.     focus = oldFocus
  2105. end updateDisplay
  2106. --*********************** Wrappers for TB30DB3.DLL calls ************************
  2107. -- All calls to the DLL are made from here. The rest of the book always
  2108. -- calls these handlers and functions to get to the DLL.
  2109. -- Simple wrapper for getDBFieldValue
  2110. to get fieldValue fieldName
  2111.     clear sysError
  2112.     get getDBFieldValue(fieldName)
  2113.     if sysError is not null
  2114.         request getDBErrorString(syserror)
  2115.         break to system -- prevent notify messages
  2116.     else
  2117.         return it
  2118.     end if
  2119.     return null
  2120. end fieldValue
  2121. -- Simple wrapper for findDBKey. Provides some feedback to the user for two
  2122. -- special cases. FindDBKey returns 3 if it can't find the text, and returns 4
  2123. -- if the search text goes past the last key.
  2124. -- Important: dBaseIII is case sensitive. "a" > "A" !!!
  2125. to handle findKey searchString
  2126.     get findDBKey(searchString)
  2127.     conditions
  2128.     when it = 3
  2129.         request stringResource("findDBKey3")    
  2130.     when it = 4
  2131.         request stringResource("findDBKey4")
  2132.         get lastDBKey()
  2133.     when it < 1
  2134.         request getDBErrorString(it)
  2135.         break to system -- prevent notify messages
  2136.     end conditions
  2137. end findKey
  2138. -- Wrapper for indexing, handles errors until it gives up.
  2139. to set index to value
  2140.     system STRING s_bookPath
  2141.     get getDBIndexFileName()
  2142.     if it is null or value is not in it
  2143.         get openDBIndexFile(s_bookPath & value)
  2144.     get checkDBIndex(s_bookPath & value)
  2145.     if it = 1 -- got it OK
  2146.         get selectDBIndexFile(s_bookPath & value)
  2147.     else
  2148.         get reindexDBFile(s_bookPath & value)
  2149.         if it = -53 -- no index with that name
  2150.             request stringIndexError(value)
  2151.             break to system
  2152.         else
  2153.             if it < 1
  2154.                 request getDBErrorString(it)
  2155.                 break to system -- prevent notify messages
  2156.             end if
  2157.         end if
  2158.     end if
  2159. end index
  2160. --- Simple wrapper for dBase navigation
  2161. to set currentRecord to value
  2162.     conditions 
  2163.     when value = "first"
  2164.         get firstDBKey()
  2165.     when value = "last"
  2166.         get lastDBKey()
  2167.     when value = "next"
  2168.         get nextDBKey()
  2169.     when value = "previous"
  2170.         get previousDBKey()
  2171.     when isType(DWORD, value) and value > 0
  2172.         get goToDBRecord(value)
  2173.     else
  2174.         break
  2175.     end conditions
  2176.     if it < 0
  2177.         if it = -10 -- no such record
  2178.         -- set a flag for updateRecords in script of field "Records" of page 1
  2179.             sysErrorNumber = 65535 
  2180.         else
  2181.             request getDBErrorString(it)
  2182.             break to system -- prevent notify messages
  2183.         end if
  2184.     end if
  2185. end currentRecord
  2186. -- Simple wrapper for setDBFieldValue
  2187. to set fieldValue fieldName to value
  2188.     get setDBFieldValue(fieldName, value)
  2189.     if it < 0
  2190.         request getDBErrorString(it)
  2191.         break to system -- prevent notify messages
  2192.     end if
  2193. end fieldValue
  2194. -- Creates a new (and empty) record.
  2195. -- We won't update the textfield until after we have created 
  2196. -- the first, last, and company names for the record.
  2197. to handle newDBRecord
  2198.     get writeDBRecord(totalRecords of this book + 1)
  2199.     if it < 0
  2200.         request getDBErrorString(it)
  2201.         break to system -- prevent notify messages
  2202.     end if
  2203. end newDBRecord
  2204. -- Simple wrapper for writeDBRecord. This is where the dBase record 
  2205. -- is actually written out.
  2206. to handle updateDB
  2207.     get writeDBRecord(currentRecord of this book)
  2208.     if it < 0
  2209.         request getDBErrorString(it)
  2210.         break to system -- prevent notify messages
  2211.     else
  2212.         send updateRecords to field "records"
  2213.     end if
  2214. end updateDB
  2215. -- Simple wrapper for setDBRecordDeleted. 
  2216. -- Note also that if we pack the dBase here, 
  2217. -- there's no recovery for a deleted file.
  2218. to handle deleteRecord packFlag
  2219.     get setDBRecordDeleted(1)
  2220.     if it < 0
  2221.         request getDBErrorString(it)
  2222.         break to system -- prevent notify messages
  2223.     end if
  2224.     if autoPack of this book is TRUE or packFlag is TRUE
  2225.         send packDataBase
  2226.     end if
  2227. end deleteRecord
  2228. -- Toggle the autoPack feature
  2229. to handle autoPack -- from menu item
  2230.     get not (menuItemChecked(autoPack)) -- the toggle
  2231.     set autoPack of this book to it
  2232.     if it is TRUE
  2233.         check menuItem autoPack
  2234.     else
  2235.         uncheck menuItem autoPack
  2236.     end if
  2237. end autoPack
  2238. -- Simple wrapper for packDBFile
  2239. to handle packDatabase
  2240.     sysCursor = 4
  2241.     -- also moves to last record in database
  2242.     -- so, to prevent that:
  2243.     if checked of button "name" of page 1
  2244.         set searchText to fieldValue(lastName)
  2245.     else
  2246.         set searchText to fieldValue(Company)
  2247.     end if
  2248.     get packDBFile()
  2249.     if it < 1
  2250.         request getDBErrorString(it)
  2251.         break to system -- prevent notify messages
  2252.     else
  2253.         send resetDBase
  2254.         send findKey searchText
  2255.         send updateDisplay
  2256.         send updateRecords to field "records"
  2257.         get totalRecords of this book
  2258.         if it > 50000
  2259.             -- Print Records can't deal with anything larger than this
  2260.             if it > 65531
  2261.                 request stringError("TooBig") 
  2262.             else
  2263.                 request stringError("AlmostTooBig")
  2264.             end if
  2265.         end if
  2266.     end if
  2267.     sysCursor = default
  2268. end packDatabase
  2269. -- workaround for dBase dll tracking problem
  2270. to handle resetDBase
  2271.     currentRecord of this book = "next"
  2272.     currentRecord of this book = "previous"
  2273. end resetDBase
  2274. --******** For functions, errors must be handled by the caller *************
  2275. -- Simple wrapper for getDBKeyValue
  2276. to get keyValue
  2277.     return getDBKeyValue()
  2278. end keyValue
  2279. -- Simple wrapper for getDBRecordNumber
  2280. to get currentRecord
  2281.     return getDBRecordNumber()
  2282. end currentRecord
  2283. -- Simple wrapper for getDBRecordCount
  2284. to get totalRecords
  2285.     return getDBRecordCount()
  2286. end totalRecords
  2287. --****************** printing ************
  2288. -- utility for printing a single record
  2289. to handle printCurrentRecord
  2290.     sysCursor = 4
  2291.     sysLockScreen = TRUE
  2292.     get objects of group "reportGroup" of page "Print Current Record"
  2293.     step i from 1 to itemCount(it)
  2294.         set text of item i of it to fieldValue(uppercase(name of item i of it))
  2295.     set tPage to this page
  2296.     linkDLL "tb30win.dll"
  2297.         STRING getWinIniVar(STRING,STRING)
  2298.     end linkDLL
  2299.     get getWinIniVar("windows","device")
  2300.     unlinkDLL "tb30Win.DLL"
  2301.     if it is NULL
  2302.         request stringResource("BadPrinter")
  2303.         sysCursor = 1
  2304.         break printCurrentRecord
  2305.     end if
  2306.     clear sysError
  2307.     sS = sysSuspend
  2308.     sysSuspend = FALSE
  2309.     start spooler
  2310.         if sysError <> NULL
  2311.             request stringResource("BadPrinter")
  2312.             sysCursor = 1
  2313.             sysLockScreen = FALSE
  2314.             sysSuspend = sS
  2315.             break printCurrentRecord
  2316.         end if
  2317.         set sysSuspend to sS
  2318.         clear printerConditions
  2319.         printerStyle = "Pages"
  2320.         go to page "Print Current Record"
  2321.         print 1 pages
  2322.     end spooler
  2323.     go to tPage
  2324.     sysLockScreen = FALSE
  2325.     sysCursor = 1
  2326. end printCurrentRecord
  2327. to handle printReport
  2328. --     for hardwired report, see code below.
  2329.     -- first check if there is a printer hooked up
  2330.     clear sysError
  2331.     sS = sysSuspend
  2332.     sysSuspend = FALSE
  2333.     linkDLL "tb30win.dll"
  2334.         STRING getWinIniVar(STRING,STRING)
  2335.     end linkDLL
  2336.     get getWinIniVar("windows","device")
  2337.     unlinkDLL "tb30Win.DLL"
  2338.     if it is NULL
  2339.         request stringResource("BadPrinter")
  2340.         sysCursor = 1
  2341.         break printReport
  2342.     end if
  2343.     -- pack the database, so that records displayed = total records of the dBase.
  2344.     request stringResource("PackDB") with stringResource("Yes") or stringResource("No")
  2345.     if it <> stringResource("Yes")
  2346.         break
  2347.     else
  2348.         send packDatabase
  2349.     end if
  2350.     -- The built in PrintReport is going to be used. Once 
  2351.     -- that's started, there is no way to control it, meaning
  2352.     -- we have to be ready to go, and by the time we get to
  2353.     -- this point, there is really no way to back out of this
  2354.     -- gracefully. So we just take a deep breath and do it.
  2355.     -- This may take a while
  2356.     sysCursor = 4
  2357.     -- nor do we want enterPage or leavePage messages.
  2358.     sysSuspendMessages = TRUE
  2359.     -- and we really don't want to see this!
  2360.     sysLockScreen = TRUE
  2361.     -- cache the current page
  2362.     tPage = this page
  2363.     -- cache the background we'll be using
  2364.     bgRB = background "report builder"
  2365.     go to first page of bgRB
  2366.     set currentRecord of this book to "First"
  2367.     -- this works because we've packed the database.
  2368.     set newPgCount to totalRecords of this book
  2369.     set rFObjs to objects of group "reportGroup" of bgRB
  2370.     -- change reference from explicit background to implicit page
  2371.     step i from 1 to itemCount(rFObjs)
  2372.         clear words 4 to 7 of item i of rFObjs
  2373.     end step
  2374.     set objCount to itemCount(rFObjs)
  2375.     -- now fill the first page, make another, fill it, etc.
  2376.     step i from 1 to newPgCount
  2377.         step j from 1 to objCount
  2378.             set text of item j of rFObjs to \
  2379.               fieldValue(uppercase(name of item j of rFObjs))
  2380.         end step
  2381.         if i < newPgCount
  2382.             set currentRecord of this book to "next"
  2383.             send newpage
  2384.         end if
  2385.     end step
  2386. --=============== allow user to custom build the report =============
  2387.     forward
  2388. --===================================================
  2389. -->>>>>>>>>>  alternative: a hardwired report   <<<<<<<<<<<
  2390. --    printerStyle = "groups"
  2391. --    step i from objCount to 1
  2392. --        push name of item i of rFObjs onto tempStack
  2393. --    end
  2394. --    printerFields = tempStack
  2395. --    printerGroupsAcross = 2
  2396. --    start spooler
  2397. --        print newPgCount pages
  2398. --    end 
  2399. --<<<<<<<<>>>>>>>>>>>
  2400.     -- now get rid of all those extra pages
  2401.     go to page 2 of bgRB
  2402.     step i from 2 to newPgCount
  2403.         send selectPage
  2404.         send clear    
  2405.     end step
  2406.     step i from 1 to objCount
  2407.         clear text of item i of rFObjs
  2408.     end step
  2409.     go to tPage
  2410.     sysCursor = 1
  2411. end printReport
  2412. --****************** Strings *********************
  2413. -- Special string functions
  2414. to get stringOpenError dbf
  2415.      return "Error opening" && dbf & ". It is needed to run this application." \
  2416.       && "Please put it in the same directory as"&& uniqueName of this book & "."
  2417. end stringOpenError
  2418. to get stringIndexError value 
  2419.     return "error opening index file:" && value & \
  2420.       ".  It is needed to run this application." && \
  2421.       "Please put it in the same directory as" && \
  2422.       uniquename of this book & "."
  2423. end stringIndexError
  2424. -- Strings for all occassions.
  2425. to get stringResource keyword
  2426.     conditions
  2427.     when keyword = ""
  2428.         return ""
  2429.     when keyword is "Edit"
  2430.         return "Ed&it"
  2431.     when keyword is "New"
  2432.         return "Ne&w"
  2433.     when keyword is "Yes"
  2434.         return "Yes"
  2435.     when keyword is "No"
  2436.         return "No"
  2437.     when keyWord is "YesNoWarning"
  2438.         return "Yes, no more warnings"
  2439.     when keyword is "escape"
  2440.         return "Cancel"
  2441.     when keyword is "DeleteWarning"
  2442.         return "This action will delete this record. Do you want to continue?"
  2443.     when keyword is "Browse"
  2444.         return "&Browse"
  2445.     when keyword is "nameSearch"
  2446.         return "Name to search for..." & CRLF & "(Search is case sensitive)"
  2447.     when keyword is "companySearch"
  2448.         return "Company to search for..." & CRLF & "(Search is case sensitive)"
  2449.     when keyword = "findDBKey3"
  2450.         if checked of button "name" = TRUE
  2451.             set keyType to "name"
  2452.         else
  2453.             set keyType to "company"
  2454.         end if
  2455.         return "String not found, next" && \
  2456.           keyType && "record becomes the current record."
  2457.     when keyword = "BadPrinter"
  2458.         return "There is a problem with the printer. Make sure it is connected and turned on."
  2459.     when keyword = "findDBKey4"
  2460.         if checked of button "name" = TRUE
  2461.             set keyType to "name"
  2462.         else
  2463.             set keyType to "company"
  2464.         end if
  2465.         return "String not found, and search string is greater than last" && \
  2466.           keyType && "record. Last record of this type becomes the current record."
  2467.     when keyword is "PackDB"
  2468.         return "This will require that all records marked for deletion are discarded." & CRLF & \
  2469.           "This can take a while if there are a lot of records. Shall we continue?" 
  2470.           
  2471.     when keyword is "contents"
  2472.         return "Contact.tbk" & CRLF & "A Simple dBaseIII Sample Application" & CRLF & \
  2473.  1994 Asymetrix Corp." & CRLF & "All Rights Reserved."
  2474.     else -- debug, not for international
  2475.         return "Error: String resource received unknown keyword" && \
  2476.         keyword && "from target" && target & "."
  2477.     end conditions
  2478. end stringResource
  2479. -- Error strings
  2480. to get stringError keyword, trgt
  2481.     conditions
  2482.     when keyword = ""
  2483.         return ""
  2484.     when keyword = "linkError"
  2485.         return "Could not link to TB30DB3.dll"
  2486.     when keyword is "NoMem"
  2487.         return "There is not enough system memory for this operation." && \
  2488.           "Please shut down other applications and try again."
  2489.     when keyword is "stringToBig"
  2490.         get getDBFieldWidth(name of trgt)
  2491.         return "This field will only accept strings up to" && it && "characters long."
  2492.     when keyword is "BadDBase"
  2493.         return "This database is not compatable with Contact.tbk. Switching to Contact.dbf"
  2494.     when keyword is "TooBig"
  2495.         return "This Contact database has become so large as to be unprintable." && \
  2496.           "This application was designed as a demonstration and was not intented for such heavy use." && \
  2497.           "You should delete records that are no longer valid, or consider using a different database application."
  2498.     when keyword is "almostTooBig"
  2499.         return "This Contact database is becoming quite large. You should consider deleting unused records."
  2500.     else -- debug, not for international
  2501.         return "Error: Error string function received unknown keyword:" && \
  2502.         keyword && "from target" && target & "."
  2503. end stringError
  2504. -- Help strings
  2505. to get stringHelp keyword
  2506.     conditions
  2507.     when keyword = ""
  2508.         return ""
  2509.     when keyword = "Edit"
  2510.         return "Toggle between browse/edit mode"
  2511.     when keyword = "New"
  2512.         return "Insert a new record into the database"
  2513.     when keyword = "Delete"
  2514.         return "Delete the current record from the database"
  2515.     when keyword = "Search"
  2516.         return "Search the database for a key in the current index"
  2517.     when keyword = "reset"
  2518.         return "Reset field values"
  2519.     when keyword = "Update"
  2520.         return "Write field values to file"
  2521.     when keyword = "Next"
  2522.         return "Go to the next record"
  2523.     when keyword = "Previous"
  2524.         return "Go to the previous record"
  2525.     when keyword = "FirstName"
  2526.         return "Enter first name"
  2527.     when keyword = "LastName"
  2528.         return "Enter last name"
  2529.     when keyword = "Company"
  2530.         return "Enter company name"
  2531.     when keyword = "Notes"
  2532.         return "Enter notes about person"
  2533.     when keyword = "BillingCD"
  2534.         return "Enter billing code if applicable"
  2535.     when keyword = "Misc"
  2536.         return "Enter other personal information"
  2537.     when keyword = "fCountryCD"
  2538.         return "Enter fax country code"
  2539.     when keyword = "fAreaCode"
  2540.         return "Enter fax area code"
  2541.     when keyword = "fLocalNum"
  2542.         return "Enter fax number"
  2543.     when keyword = "fExtension"
  2544.         return "Enter fax extension"
  2545.     when keyword = "vCountryCD"
  2546.         return "Enter voice country code"
  2547.     when keyword = "vAreaCode"
  2548.         return "Enter voice area code"
  2549.     when keyword = "vLocalNum"
  2550.         return "Enter voice phone number"
  2551.     when keyword = "vExtension"
  2552.         return "Enter voice extension"
  2553.     when keyword = "name"
  2554.         return "Sort the records by last name first"
  2555.     when keyword = "companyButton"
  2556.         return "Sort the records by company first"
  2557.     when keyword = "viewByCompany"
  2558.         return "View name and company fields"
  2559.     when keyword = "viewByPhone"
  2560.         return "View name and phone fields"
  2561.     when keyword is "Records"
  2562.         if caption of button "Edit" is stringResource("Edit")
  2563.             return "Doubleclick to edit selection"
  2564.         else
  2565.             return "Doubleclick to browse selection"
  2566.         end if
  2567.     else -- debug, not for international
  2568.         return "Error: Help string function received unknown keyword:" && \
  2569.         keyword && "from target" && target & "."
  2570.     end conditions
  2571. end stringHelp
  2572. DBEXCHNG.TBK
  2573. R--***************************************************************************
  2574. --                Asymetrix dBase - Paradox - ToolBook Exchange
  2575. --                          1991 - 1994
  2576. --                          Asymetrix Corporation
  2577. --Copyright 
  2578.  1991-1994 Asymetrix Corporation
  2579. --This version authored by Jeff Ayars and Charles Hiestand
  2580. --Asymetrix gives you permission to copy, revise and reuse the individual 
  2581. --objects and scripts in this application in your own applications.  
  2582. --You may not, however, copy the entire book (or a substantial part of it) 
  2583. --for redistribution as your own product.
  2584. --Asymetrix retains the copyright on the original elements of this 
  2585. --application. Include the notice "Portions of this application are the 
  2586. --copyright of Asymetrix Corporation" in your product if they contain 
  2587. --objects or scripts copied from this application.
  2588. --A note on language independence:  For ease of translating this 
  2589. --application, all text strings visible to readers that come from scripts 
  2590. --are put into functions located at the bottom of this book script.  
  2591. --The names of these functions start with the letters: "str".
  2592. --  handlers in this script:
  2593. --      author                      set prompt for save changes
  2594. --      enterApplication            handle housekeeping
  2595. --      leaveApplication            clean up
  2596. --      leavePage                   clean up per page
  2597. --      ImportdBase                    go to option
  2598. --      ExportdBase                   go to option
  2599. --      dBaseHelp                   go to help page
  2600. --      linkFile                    link tb30DOS.dll functions
  2601. --      linkdBase                   link tb30db3.dll functions
  2602. --        last                        go to page 10 if in reader
  2603. --  User defined functions in this script:
  2604. --      isAlNum                     test for alphaNumeric
  2605. --      isNum                       test for numeric
  2606. --      isAlpha                     test for alphabetic
  2607. --      isPosInt                    test for positive integer
  2608. --         nameOnly                    return prefix of file name only.
  2609. --***************************************************************************
  2610. to handle enterApplication
  2611.     system s_firstFlag
  2612.     s_firstFlag = true
  2613.     set sysChangesdb to FALSE
  2614.     if sysRuntime is TRUE
  2615.         request strRuntime()
  2616.         send exit to system
  2617.         break to system
  2618.     end if
  2619.     send reader
  2620.     show mainWindow
  2621.     show viewer "splash"
  2622.     send linkFile
  2623.     send linkdBase
  2624.     send linkPX
  2625.     get initializePX("DBExchange")
  2626.     if it < 0 -- if SHARE.EXE is not running, an error will occur here
  2627. --        request getPXErrorString(it)
  2628.         request "DBEXCHNG.TBK needs SHARE.EXE to work correctly. Please leave Windows and from the DOS prompt type ""share"" followed by the enter key. You can then re-enter Windows and start DBEXCHNG.TBK"
  2629.         request "DBEXCHNG.TBK will now exit."
  2630.         send exit to system
  2631.         break to system
  2632.     end if
  2633.     send sizeToPage  -- center window on screen
  2634.        pause 2 seconds
  2635.     forward
  2636.     close viewer "splash"
  2637. end enterApplication
  2638. to handle leaveApplication   
  2639.     get exitPX()
  2640.     forward
  2641. end leaveApplication
  2642. to handle idle -- make sure the screen is centered
  2643.         --(sometimes in 640 X 480 there is a problem)
  2644.     system s_firstFlag
  2645.     forward
  2646.     if s_firstFlag = TRUE
  2647.         send sizeToPage
  2648.         clear s_firstFlag
  2649.     end if
  2650. end idle
  2651. --ask to saveChanges if they have switched to author mode.
  2652. to handle author
  2653.     set sysChangesDB to TRUE
  2654.     forward
  2655.     send sizeToPage
  2656. end author
  2657. to handle reader
  2658.     forward
  2659.     send sizeToPage
  2660. end reader
  2661. to handle last
  2662.     if sysLevel is reader
  2663.         go to page "Export"
  2664.     else
  2665.         forward
  2666.     end if
  2667. end last
  2668. --*********************************************************************
  2669. --handlers for custom menu alias messages
  2670. --*********************************************************************
  2671. to handle menuItemSelected menuItem, menuAlias
  2672.     conditions
  2673.     when menuItem is "ImportFromDbaseFile"
  2674.         go to page "import Dbase"
  2675.     when menuItem is "ExportToDbase"
  2676.         go to page "export DBase"
  2677.     when menuItem is "ImportFromParadox"
  2678.         go to page "import Paradox"
  2679.     when menuItem is "ExportToParadox"
  2680.         go to page "export Paradox"
  2681.     else
  2682.         forward
  2683.     end conditions
  2684. end menuItemSelected
  2685. to handle dBaseHelp
  2686.     system STRING svReturnPage
  2687.     syscursor = 4
  2688.     -- Do not want to send leave or enterPage because user will
  2689.     -- lose work
  2690.     sysSuspendMessages = TRUE
  2691.     -- Do not modify return page if they are already in help
  2692.     if name of this background <> "exchangeHelp"
  2693.         svReturnPage = name of this page
  2694.     end if
  2695.     if name of this page contains "export"
  2696.         go to page "exporting ToolBook to dBase"
  2697.     else
  2698.         go to page "importing dBase to Toolbook"
  2699.     end if
  2700.     sysCursor = default  -- needed because syssuspendmessages set to TRUE
  2701. end dBaseHelp
  2702. to handle aboutdBase
  2703.     show viewer "splash"
  2704. --    request strAboutDbase()
  2705. end aboutdBase
  2706. --*****************************************************************************
  2707. --handlers to link DLL functions used by the book
  2708. --*****************************************************************************
  2709. --link functions for file dll
  2710. to handle linkFile
  2711.     sysSuspend = FALSE
  2712.     clear sysError
  2713.     linkDLL sysToolBookDirectory & "tb30dos.dll"
  2714.         INT    fileExists(STRING)
  2715.         STRING getFileList(STRING)
  2716.     end linkDLL
  2717.     if syserror is not null
  2718.         request strNoDll ("TB30DOS.DLL")
  2719.         send exit to system
  2720.         break to system
  2721.     end if
  2722.     set syserror to null
  2723.     linkDLL sysToolBookDirectory & "tb30dlg.dll"
  2724.         STRING OpenFileDlg(STRING,STRING,STRING,STRING,INT)
  2725.         STRING saveAsDlg(STRING,STRING,STRING,STRING,INT)
  2726.     end linkDLL
  2727.     if syserror is not null
  2728.         request strNoDll ("TB30DLG.DLL")
  2729.         send exit to system
  2730.         break to system
  2731.     end if
  2732.     linkDLL "kernel"
  2733.         WORD GlobalAlloc(WORD,DWORD)
  2734.         WORD GlobalFree(WORD)
  2735.         POINTER GlobalLock(WORD)
  2736.         WORD GlobalUnlock(WORD)
  2737.     end linkDLL
  2738.     sysSuspend = TRUE
  2739. end linkFile
  2740. to handle linkdBase
  2741.     sysSuspend = FALSE
  2742.     clear sysError
  2743.     linkdll sysToolBookDirectory & "tb30DB3.DLL"
  2744.         INT checkDBIndex(STRING)
  2745.         INT closeAllDBFiles()
  2746.         INT closeDBFile(STRING)
  2747.         INT closeDBIndexFile(STRING)
  2748.         WORD createDBFieldTag(WORD)
  2749.         INT createDBFile(STRING,WORD,WORD)
  2750.         INT createDBIndexFile(STRING,STRING,WORD,WORD)
  2751.         INT deleteDBFile(STRING)
  2752.         INT deselectDBIndexFile()
  2753.         INT findDBKey(STRING)
  2754.         INT firstDBKey()
  2755.         INT firstDBRecord()
  2756.         INT freeDBFieldTag(WORD)
  2757.         STRING getDBDateFormat()
  2758.         STRING getDBErrorString(INT)
  2759.         INT getDBFieldCount()
  2760.         STRING getDBFieldName(WORD)
  2761.         INT getDBFieldPrecision(STRING)
  2762.         INT getDBFieldType(STRING)
  2763.         STRING getDBFieldValue(STRING)
  2764.         INT getDBFieldWidth(STRING)
  2765.         STRING getDBFileName()
  2766.         STRING getDBIndexExpression()
  2767.         STRING getDBIndexFileName()
  2768.         INT getDBKeyType()
  2769.         STRING getDBKeyValue()
  2770.         INT getDBNavigateToDeleted()
  2771.         LONG getDBRecordCount()
  2772.         INT getDBRecordDeleted()
  2773.         LONG getDBRecordNumber()
  2774.         INT gotoDBRecord(DWORD)
  2775.         INT lastDBKey()
  2776.         INT lastDBRecord()
  2777.         INT nextDBKey()
  2778.         INT nextDBRecord()
  2779.         INT openDBFile(STRING)
  2780.         INT openDBIndexFile(STRING)
  2781.         INT packDBFile()
  2782.         INT previousDBKey()
  2783.         INT previousDBRecord()
  2784.         INT reindexDBFile(STRING)
  2785.         INT removeDBRecords(DWORD,DWORD)
  2786.         INT selectDBFile(STRING)
  2787.         INT selectDBIndexFile(STRING)
  2788.         INT setDBDateFormat(STRING)
  2789.         INT setDBFieldTag(WORD,WORD,STRING,STRING,WORD,WORD)
  2790.         INT setDBFieldValue(STRING, STRING)
  2791.         INT setDBNavigateToDeleted(INT)
  2792.         INT setDBRecordDeleted(WORD)
  2793.         INT writeDBRecord(DWORD)
  2794.     end linkdll
  2795.      if sysError <> null
  2796.         request "Could not link to TB30db3.dll"
  2797.     end    if
  2798.     set sysSuspend to true
  2799.     if sysError <> null
  2800.         request strNoDLL("TB30DB3.DLL")
  2801.     end if
  2802.     sysSuspend = TRUE
  2803. end linkdBase
  2804. to handle linkPX
  2805.     -- all are linked, not all are used
  2806.     linkDLL sysToolBookDirectory & "tb30PDX.DLL"
  2807.         INT addPXKey(STRING,STRING,INT)                --PXKeyAdd()
  2808.         INT addPXPassword(STRING)                    --PXPswAdd()
  2809.         INT addPXTable(STRING,STRING)                --PXTblAdd()
  2810.         INT appendPXRecord(STRING)                    --PXRecAppend()
  2811.         INT clonePXBlob(STRING,STRING)                --PXBlobClone()
  2812.         INT closePXBitmapWindow(WORD)
  2813.         INT closePXBlob(INT,INT)                    --PXBlobClose()
  2814.         INT closePXTable(STRING)                    --PXTblClose()
  2815.         INT copyPXTable(STRING,STRING)                --PXTblCopy()
  2816.         INT createPXTable(STRING,STRING,STRING)        --PXTblCreate()
  2817.         INT decryptPXTable(STRING)                    --PXTblDecrypt()
  2818.         INT deletePXPassword(STRING)                --PXPswDel()
  2819.         INT deletePXRecord(STRING)                    --PXRecDelete()
  2820.         INT deletePXTable(STRING)                    --PXTblDelete()
  2821.         INT doesPXTableExist(STRING)                --PXTblExist()
  2822.         INT dropPXBlob(STRING,STRING)                --PXBlobDrop()
  2823.         INT dropPXKey(STRING,STRING,WORD)            --PXKeyDrop()
  2824.         INT emptyPXField(STRING,STRING)
  2825.         INT emptyPXRecord(STRING)                    --PXRecBufEmpty()
  2826.         INT emptyPXTable(STRING)                    --PXTblEmpty()
  2827.         INT encryptPXTable(STRING,STRING)            --PXTblEncrypt()
  2828.         INT exitPX()                                --PXExit()
  2829.         INT freePXGraphicBlob(WORD)
  2830.         INT freePXGraphicBlobPalette(WORD)
  2831.         INT firstPXRecord(STRING)                    --PXRecFirst()
  2832.         LONG getPXBitmapSize(WORD)
  2833.         LONG getPXBlob(INT,DWORD,LONG)                --PXBlobGet()
  2834.         LONG getPXBlobQuick(STRING,STRING,INT)        --PXBlobQuickGet()
  2835.         LONG getPXBlobSize(INT)                        --PXBlobGetSize()
  2836.         STRING getPXErrorString(INT)                --return error string
  2837.         INT getPXFieldCount(STRING)                    --PXRecNFlds()
  2838.         STRING getPXFieldNames(STRING)
  2839.         STRING getPXFieldType(STRING,STRING)        --PXFldType()
  2840.         STRING getPXFieldValue(STRING,STRING)
  2841.         LONG getPXFileSize(STRING)
  2842.         LONG getPXGraphicBlob(INT)
  2843.         LONG getPXGraphicBlobPalette(INT)
  2844.         INT getPXKeyFieldCount(STRING)                --PXKeyNFlds()
  2845.         INT getPXMaxFiles()
  2846.         INT getPXMaxLocks()
  2847.         INT getPXMaxTables()
  2848.         INT    getPXSwapSizeFromINI()
  2849.         INT    getPXMaxTablesFromINI()
  2850.         INT    getPXMaxFilesFromINI()
  2851.         INT    getPXMaxLocksFromINI()
  2852.         STRING getPXMemoBlob(INT)
  2853.         STRING getPXNetErrorUser()                    --PXNetErrUser()
  2854.         STRING getPXNetUserName()                    --PXNetUserName()
  2855.         LONG getPXRaw(STRING,INT)                    --PXRawGet()
  2856.         INT getPXRawDataSize(STRING)
  2857.         LONG getPXRecordCount(STRING)                --PXTblNRecs()
  2858.         LONG getPXRecordNumber(STRING)                --PXRecNum()
  2859.         STRING getPXSortOrder()
  2860.         INT getPXSwapSize()
  2861.         STRING getPXUserInfo()
  2862.         INT gotoPXNetRecordLock(STRING,INT)            --PXNetRecGotoLock()
  2863.         INT gotoPXRecord(STRING,LONG)                --PXRecGoto()
  2864.         INT initializePX(STRING)                    --PXWinInit()
  2865.         INT insertPXRecord(STRING)                    --PXRecInsert()
  2866.         INT isPXNetRecordLocked(STRING)                --PXNetRecLocked()
  2867.         INT isPXNetTableChanged(STRING)                --PXNetTblChanged()
  2868.         INT isPXTableProtected(STRING)                --PXTblProtected()
  2869.         INT lastPXRecord(STRING)                    --PXRecLast()
  2870.         INT lockPXNetFile(STRING,INT)                --PXNetFileLock()
  2871.         LONG lockPXNetRecord(STRING)                --PXNetRecLock()
  2872.         INT lockPXNetTable(STRING,INT)                --PXNetTblLock()
  2873.         LONG mapPXKey(STRING,STRING,STRING,INT)        --PXKeyMap()
  2874.         INT nextPXRecord(STRING)                    --PXRecNext()
  2875.         LONG openPXBitmapWindow(WORD,WORD,WORD,STRING,INT,STRING)
  2876.         LONG openPXBlobRead(STRING,STRING)            --PXBlobOpenRead()
  2877.         LONG openPXBlobWrite(STRING,STRING,LONG,INT)--PXBlobOpenWrite()
  2878.         INT openPXTable(STRING,STRING,INT,INT)        --PXTblOpen()
  2879.         INT packPXTable(STRING)
  2880.         INT previousPXRecord(STRING)                --PXRecPrev()
  2881.         STRING queryPXKey(STRING)                    --PXKeyQuery()
  2882.         INT refreshPXNetTable(STRING)                --PXNetTblRefresh()
  2883.         INT renamePXTable(STRING,STRING)            --PXTblRename()
  2884.         INT savePX()                                --PXSave()
  2885.         INT searchPXField(STRING,STRING,WORD,INT)    
  2886.         INT searchPXKey(STRING,INT,STRING,INT)        --PXSrchKey()
  2887.         INT setPXBitmapWindowInfo(WORD,WORD,WORD,INT,STRING)
  2888.         INT setPXBlob(INT,DWORD,LONG,WORD)            --PXBlobPut()
  2889.         INT setPXBlobFromFile(INT,DWORD,DWORD,DWORD,STRING)--PXBlobPut()
  2890.         INT setPXFieldValue(STRING,STRING,STRING)    --PXPutAlpha(), PXPutDate(), PXPutDouble(), PXPutLong(), PXPutShort()
  2891.         INT    setPXGraphicBlob(INT,WORD,WORD)            --PXBlobPut()
  2892.         INT setPXGraphicBlobFromFile(INT,STRING)    --PXBlobPut()
  2893.         INT setPXINIMaxFiles(INT)                    --PXSetDefaults()
  2894.         INT setPXINIMaxLocks(INT)                    --PXSetDefaults()
  2895.         INT setPXINIMaxTables(INT)                    --PXSetDefaults()
  2896.         INT setPXMemoBlob(INT,STRING)                --PXBlobPut()
  2897.         INT setPXRaw(STRING,INT,INT)                --PXRawPut()
  2898.         INT setPXSortOrder(STRING)
  2899.         INT setPXINISwapSize(INT)
  2900.         INT setPXTableCreateMode(INT)                --PXTblCreateMode()
  2901.         INT setPXTableMaxSize(INT)                    --PXTblMaxSize()
  2902.         INT setPXUserInfo(STRING)
  2903.         INT unlockPXNetFile(STRING,INT)                --PXNetFileUnlock()
  2904.         INT unlockPXNetRecord(STRING,INT)            --PXNetRecUnlock()
  2905.         INT unlockPXNetTable(STRING,INT)            --PXNetTblUnlock()
  2906.         INT updatePXRecord(STRING)                    --PXRecUpdate()
  2907.         INT upgradePXTable(STRING)                    --PXTblUpgrade()
  2908.         LONG writePXBlobToFile(INT,STRING,INT)        --PXBlobPut()
  2909.         LONG writePXGraphicBlobToFile(INT,STRING,INT)--PXBlobPut()
  2910.       end linkDLL
  2911.       clear sysError
  2912. end linkPX
  2913. --*************************************************************************
  2914. --Functions to support data validation and error checking
  2915. --*************************************************************************
  2916. -- We test the ANSI number of each character. 
  2917. -- See page C-4 (appendix C) of the ToolBook User Manual.
  2918. to get isAlNum string
  2919.     local LONG i
  2920.     step i from 1 to charCount(string)
  2921.         get charToAnsi(char i of string)
  2922.         if (it >= 0  and it <= 47)  or \ 
  2923.            (it >= 91  and it <= 96) or \ 
  2924.            (it >= 58  and it <= 64)    
  2925.             return FALSE
  2926.         end if
  2927.     end step
  2928.     return TRUE
  2929. end isAlNum
  2930. to get isAlpha string
  2931.     local INT i
  2932.     step i from 1 to charCount(string)
  2933.         get charToAnsi(char i of string)
  2934.         if ( it >= 0  and it <= 64)  or (it >= 91  and it <= 96) or (it > 127)
  2935.             return FALSE
  2936.         end if
  2937.     end step
  2938.     return TRUE
  2939. end isAlpha
  2940. -- Instead of replacing ever call to these ToolBook 1.5 functions,
  2941. -- they have been rewritten using the new 3.0 functionality.
  2942. to get isNum str
  2943.     return isType(REAL, str)
  2944. end isNum
  2945. --boolean test for a positive integer
  2946. to get isPosInt str
  2947.     return evaluate(isType(INT,str) and str >= 0)
  2948. end isPosInt
  2949. -- get just the file name from a fully qualified path
  2950. to get nameOnly fFile
  2951.     local WORD vOffset
  2952.     set vOffset to offset ("\",fFile)
  2953.     while vOffset > 0
  2954.         clear chars 1 to vOffset of fFile
  2955.         set vOffset to offset ("\",fFile)
  2956.     end while
  2957.     return fFile
  2958. end nameOnly
  2959. to get strHelp
  2960.     return "Help"
  2961. end strHelp
  2962. to get strAboutDbase
  2963.     -- debug: better about
  2964.     return "dBaseIII (tm) - Paradox (tm) - ToolBook (tm) Exchange" & crlf & \
  2965.       "Copyright (c) 1991 - 1994 -- Asymetrix Corporation" 
  2966. end strAboutDbase
  2967. to get strCloseInstances
  2968.     return "Please close all other instances of ToolBook."
  2969. end strCloseInstances
  2970. to get strRuntime
  2971.     return "This application will only work with the full authoring ToolBook system. It will now close, please restart it using mtb30.EXE"
  2972. end strRuntime
  2973. to get strdbf
  2974.     return "&dBase"
  2975. end strdbf
  2976. to get strDBFileCreationError fName
  2977.     return "There was an error creating dBase file:" && fName
  2978. end strDBFileCreationError
  2979. to get strDBFileOpenError fName
  2980.     return "There was an error opening dBase file:" && fName
  2981. end strDBFileOpenError
  2982. to get strErrNoDBF
  2983.     return "There is no current dBase file. Please select one."
  2984. end strErrNoDBF
  2985. to get strErrRefdbField fField
  2986.     return "Error referencing dBase field:  " & fField
  2987. end strErrRefdbField
  2988. to get strErrDBFWrite
  2989.     return "Error writing dBase record."
  2990. end strErrDBFWrite
  2991. to get strErrSetDBF fField
  2992.     return "There was an error setting value of dBase field: " & fField
  2993. end strErrSetDBF
  2994. to get strErrTag
  2995.     return "Error creating dBase field tag."
  2996. end strErrTag
  2997. to get strErrTbkExe
  2998.     request "There was an error running mtb30.exe."
  2999.     return FALSE
  3000. end strErrTbkExe
  3001. to get strExportDone errCount
  3002.     if errCount = 0
  3003.         return "Export completed."
  3004.     else
  3005.         return "Export completed:  There were" && errCount && "field(s) with" && \
  3006.                 "invalid data."
  3007.     end if
  3008.     return "Export completed."
  3009. end strExportDone
  3010. to get strNoDBFFields
  3011.     return "No dBase fields have been selected yet."
  3012. end strNoDBFFields
  3013. to get strNoDLL fName
  3014.     return "Can't find" && fName & ". Please copy this file to a directory that's in your path, or change your path to include"&&fname&"'s directory, then open this book again."
  3015. end strNoDLL
  3016. to get strSelTBFields
  3017.     return "Please select ToolBook fields for export."
  3018. end strSelTBFields
  3019. to get strSetDBName
  3020.     return "Please enter a dBase file name."
  3021. end strSetDBName
  3022. to get strTagErr index
  3023.     return "Error setting field tag for field " && index & "." 
  3024. end strTagErr
  3025. to get strTBErrorRef fName
  3026.     return "There was an error referencing book:  " & fname
  3027. end strTBErrorRef
  3028. to get strTBrecordError fField
  3029.     return "Error referencing record field:" && fField
  3030. end strTBrecordError
  3031. to get strEnterDBfile
  3032.     return "Please enter a valid dBase file name."
  3033. end strEnterDBfile
  3034. to get strNoOpenDBfile
  3035.     return "File cannot be opened.  Please enter a valid dBase file name."
  3036. end strNoOpenDBfile
  3037. to get strNoNameOrType
  3038.     return "There is no name or type for one of the fields. Please set the values."
  3039. end strNoNameOrType
  3040. to get strSeldBFileName
  3041.     return "Please select a dBase file name."
  3042. end strSeldBFileName
  3043. to get strErrListdBFile
  3044.     return "Error listing fields for this dBase file."
  3045. end strErrListdBFile
  3046. to get strSelTBKFileName
  3047.     return "Please select a ToolBook file name."
  3048. end strSelTBKFileName
  3049. to get strNoNameRecFfl
  3050.     return "No named, ungrouped record fields were found on the last page of this ToolBook file."
  3051. end strNoNameRecFfl
  3052. to get strTwoShareName
  3053.     return "Two or more record fields share the same name in this book.  Please give all recordfields unique names."
  3054. end strTwoShareName
  3055. to get strNoRecIndBase
  3056.     return "There are no records in this dBase file."
  3057. end strNoRecIndBase
  3058. to get strErrorFirstdBRec
  3059.     return "Error getting the first record in this dBase file."
  3060. end strErrorFirstdBRec
  3061. to get strErrorGetdBValue curFld, totrecs
  3062.     return "Error getting value for field" && \
  3063.       curFld && "in record number" && totrecs & "."
  3064. end strErrorGetdBValue
  3065. to get strErrSetdBValue curfld, totrecs
  3066.     return "Error setting value for record field" && \
  3067.       curfld && "in record number" && totrecs & "."
  3068. end strErrSetdBValue
  3069. to get strToManyFlds
  3070.     return "You are importing more fields than can be displayed on the page." && \
  3071.       "You will have to arrange the fields after the book is built."
  3072. end strToManyFlds
  3073. to get strOK
  3074.     return "OK"
  3075. end strOK
  3076. to get strCancel
  3077.     return "Cancel"
  3078. end strCancel
  3079. to get strPlChooseBook
  3080.     return "Please choose the book to export."
  3081. end strPlChooseBook
  3082. to get strChooseBook
  3083.     return "Choose Book"
  3084. end strChooseBook
  3085. to get strPlChooseDbase
  3086.     return "Please choose the dBase file to import."
  3087. end strPlChooseDbase
  3088. to get strChoosedBase
  3089.     return "Choose dBase File"
  3090. end strChoosedBase
  3091. to get strFieldOverrun fType
  3092.     return "You have exceeded the size limits of a " & fType && ".dbf field."
  3093. end strFieldOverrun
  3094. to get strPrecisionError
  3095.     return "Decimal precision must be either zero or at least two less than the field width."
  3096. end strPrecisionError
  3097. to get strAskDateFormat fldName
  3098.     return "Enter the ToolBook date format of the text in record field" && \
  3099.       fldName & "."
  3100. end strAskDateFormat
  3101. to get strdBnameExist dbName
  3102.     return "Filename" && dbName && "already exists. Replace it?"
  3103. end strdBnameExist
  3104. to get strSavedBaseFile
  3105.     return "Save dBase file as:"
  3106. end strSavedBaseFile
  3107. to get strSavePXFile
  3108.     return "Save Paradox file as:"
  3109. end strSavePXFile
  3110. to get strCharWidth
  3111.     return "Character width must be between 1 and 255."
  3112. end strCharWidth
  3113. to get strNumWidth
  3114.     return "Numeric width must be between 1 and 19."
  3115. end strNumWidth
  3116. to get strWidthNull
  3117.     return "Width cannot be blank."
  3118. end strWidthNull
  3119. to get strDecimalNull
  3120.     return "Decimal cannot be blank."
  3121. end strDecimalNull
  3122. to get strDecimal15
  3123.     return "Decimal cannot be greater than 15."
  3124. end strDecimal15
  3125. to get strNameToLarge
  3126.     return "A dBase field name can only be up to 10 characters."
  3127. end strNameToLarge
  3128. to get strNameNull
  3129.     return "A dBase field name cannot have a blank name." 
  3130. end strNameNull
  3131. to get strChar1Num
  3132.     return "A dBase field name cannot start with a number."
  3133. end strChar1Num
  3134. to get strNotPage
  3135.     return "This is not a functioning page for this book.  It is used to build the front end."
  3136. end strNotPage
  3137. to get strYes
  3138.     return "Yes"
  3139. end strYes
  3140. to get strTooTooManyFields num
  3141.     return "You can only build the new application with" && num && "fields if you" \
  3142.                && "don't include label fields. Do you want to eliminate the label fields?"
  3143. end strTooTooManyFields
  3144. to get strWayTooManyFields
  3145.     return "You have selected more fields than this application can handle." \
  3146.                  && "Please try again with less fields."
  3147. end strWayTooManyFields
  3148. to get strNoLabels
  3149.     return "No label fields"
  3150. end strNoLabels
  3151. to get strNo
  3152.     return "No"
  3153. end strNo
  3154. ANIMATE.TBK
  3155.  1993,1994. Asymetrix Corporation. All Rights Reserved.
  3156. -- Asymetrix gives you permission to copy, revise, and reuse the
  3157. -- individual objects and scripts in this application in your own
  3158. -- applications.  You may not copy the entire book (or a
  3159. -- substantial part of it) for redistribution as your own product.
  3160. -- Asymetrix retains the copyright on the original elements of this
  3161. -- application. Include the notice "Portions 
  3162.  1993, 1994. 
  3163. -- Asymetrix Corporation. All Rights Reserved." in your product 
  3164. -- if they contain objects or scripts copied from this application.
  3165. -- tableOfContents message sent by toolbar send when the 
  3166. -- tableOfContents is pressed
  3167. --============== Standard ToolBook messages ===================
  3168. -- set up the menus, initialize Back handling
  3169. to handle enterApplication
  3170.     forward
  3171.     set enabled of button "back" of page "toolbar" to false
  3172.     if sysRuntime is false
  3173.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  3174.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  3175.          "Displays/hides Template Outline palette."
  3176.         add menuitem "" to menu "contents" at author
  3177.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  3178.          "Adds new chapter to this book."
  3179.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  3180.          "Changes name of current chapter."
  3181.         add menuitem "" to menu "contents" at author
  3182.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  3183.          "Adds new topic to this chapter."
  3184.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  3185.          "Changes name of topic chapter."
  3186.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  3187.          "Displays help on using this template."
  3188.         if firstTime of this book is not false
  3189.             open viewer "outline"
  3190.             send rebuildStructure
  3191.             firstTime of this book = false
  3192.         end
  3193.     if not animSysbookLoaded()
  3194.         request "The path animation sysbook is not loaded. Animations in the ""Path Animation"" sections will not run. Be sure that either mtb30.sbk or mtb30ani.sbk are included in your startupSysbooks."
  3195.     hide button "help" of page "toolbar"
  3196.     -- initialize checkmarks
  3197.     bk = topicsBackground()
  3198.     step i from 1 to pagecount of bk
  3199.         set visited of page i of bk to false
  3200.     set checked of group "tableofcontents" of page "tableOfContents" to false
  3201.     if syslevel is author
  3202.         send reader
  3203. to handle entermenu menuName,menuAlias
  3204.     if menuName is "contents" and syslevel is author
  3205.         if this background is chaptersBackground() 
  3206.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  3207.         else
  3208.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  3209.         end
  3210.         if this background is TopicsBackground() 
  3211.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  3212.         else
  3213.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  3214.         end
  3215.         if visible of viewer "outline"
  3216.             check menuitem "outline"  in menu "contents" at author
  3217.         else
  3218.             uncheck menuitem "outline"  in menu "contents" at author
  3219.         end
  3220.     forward
  3221. to handle leaveapplication
  3222.     remove menu "Contents" at author
  3223.     remove menuitem "helpTemplate" in menu "help" at author
  3224.     forward
  3225. to handle author
  3226.     if isOpen of viewer "outline"
  3227.         set fw to focusWindow
  3228.         show viewer "outline"
  3229.         set focusWindow to fw
  3230.     show button "help" of page "toolbar"
  3231.     forward
  3232. to handle reader
  3233.     forward
  3234.     if isOpen of viewer "outline"
  3235.         hide viewer "outline"
  3236.     hide button "help" of page "toolbar"
  3237.     send sizeToPage
  3238. to handle outline
  3239.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  3240.     if mstate is true
  3241.         if isOpen of viewer "outline"
  3242.             close viewer "outline"
  3243.         end
  3244.     else
  3245.         open viewer "outline"
  3246.         send rebuildStructure
  3247.         show viewer "outline"
  3248. -- if a newbackground is inserted into the content area,
  3249. -- move it beyond the content area
  3250. to handle newBackground
  3251.     get chapterCount of this book
  3252.     if it < chapterLimit()
  3253.         forward
  3254.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  3255.                        pagenumber of last page of topicsBackground())
  3256.         if pagenumber of this page < lastPage
  3257.             pageNumber of this page = lastPage
  3258.         end
  3259.     else
  3260.         request "This template is limited to" && chapterLimit() && "chapters."
  3261. --================ Utility handlers ===================
  3262. -- returns number of chapters allowed in this template
  3263. to get chapterLimit
  3264.     return 8
  3265. -- returns the background reference for the chapter headings background
  3266. to get chaptersBackground
  3267.     return background "chapter headings"
  3268. -- returns the background reference for the chapter topics background
  3269. to get topicsBackground
  3270.     return background "topics"
  3271. to handle rebuildStructure updatePalette
  3272.     if updatePalette is null
  3273.         updatePalette = true
  3274.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  3275.     pageNumber of page "tableofcontents" = 1
  3276.     pagenumber of first page of chaptersBackground() = 2
  3277.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  3278.                    pagenumber of last page of topicsBackground())
  3279.     pageCounter = 2
  3280.     chapterCount = 0
  3281.     while pageCounter <= lastPage
  3282.         curPage = page pageCounter
  3283.         curPageId = idnumber of curPage
  3284.         curBackground = parent of curPage
  3285.         pagelabel = label of curPage
  3286.         conditions
  3287.             when curBackground is chaptersBackground()
  3288.                 increment chapterCount
  3289.                 if prevChapterHeadingPage is not NULL
  3290.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  3291.                     clear pagesOfEachChapter
  3292.                 end
  3293.                 prevChapterHeadingPage = curPage
  3294.                 curChapterId = curPageId
  3295.                 myChapterID of curPage = curChapterID
  3296.                 if chapterList is not null
  3297.                     put crlf after chapterList
  3298.                 end
  3299.                 put curPageId & "," & pageLabel after chapterList
  3300.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  3301.                 increment pageCounter
  3302.             when curBackground is topicsBackground()
  3303.                 if pagesOfEachChapter is not null
  3304.                     put "," after pagesOfEachChapter
  3305.                 end
  3306.                 put idnumber of curPage after pagesOfEachChapter
  3307.                 myChapterID of curPage = curChapterID
  3308.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  3309.                 increment pageCounter
  3310.         else
  3311.             -- this page is not of either background. Move it beyond both backgrounds
  3312.             pageNumber of curPage = lastPage
  3313.             decrement lastPage    
  3314.         end
  3315.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  3316.     voutline of group "tableOfContents" of page "tableOfContents" = chapterList
  3317.     clear last char of listBoxText
  3318.     clear last char of listBoxText
  3319.     if updatePalette
  3320.         if isOpen of viewer "outline"
  3321.             send initPage listBoxText to currentPage of viewer "outline"
  3322.         end
  3323.     in mainWindow
  3324.         send initPage to this page
  3325.     chapterCount of this book = chapterCount
  3326. -- Used to get the text before a tab of a textline
  3327. -- (in the list box of a dialog viewer, tab is used 
  3328. -- to store extra information that gets clipped by the 
  3329. -- right side of the field)
  3330. to get extractName t
  3331.     if first char of t is tab
  3332.         clear first char of t
  3333.     tabOffset = offset(tab,t)
  3334.     if tabOffset is 0
  3335.         return null
  3336.     else
  3337.         return chars 1 to tabOffset-1 of t
  3338. -- Used to get the text beyond a tab of a textline
  3339. to get extractID t
  3340.     lastTabLoc = charcount(t)
  3341.         decrement lastTabLoc
  3342.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  3343.     if lastTabLoc <=0
  3344.         return null
  3345.     else
  3346.         return chars lastTabLoc+1 to charcount(t) of t
  3347. -- returns the numerical location of an item in a list
  3348. to get itemOffset itm,lst
  3349.     step i from 1 to itemcount(lst)
  3350.         pop lst
  3351.         if it = itm
  3352.             return i
  3353.         end
  3354.     return 0
  3355. -- returns a gray color
  3356. to get middleGray
  3357.     return 240,63.5,2.1875
  3358. -- returns dark blue
  3359. to get darkBlue
  3360.     return 240,25.125,100
  3361. -- returns a string of tabs. This serves a spacer between the 
  3362. -- label of a page and the idnumber on each line in the listbox. 
  3363. -- This is used so the idnumber is clipped and not visible
  3364. to get tabSpacer
  3365.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  3366. --============= Navigation and menu messages =============
  3367. -- tableOfContents message sent by toolbar
  3368. -- when the tableOfContents button is pressed
  3369. to handle tableOfContents
  3370.     pref = page "tableOfContents"
  3371.     send updatechecks to group "tableofcontents" of pref
  3372.     go to pref
  3373. to handle helpTemplate
  3374.     mydir = name of self
  3375.         clear last char of mydir
  3376.     until last char of mydir is "\" or mydir is null
  3377.     sen = sysErrorNumber
  3378.     se = sysError
  3379.     sysErrorNumber = 0
  3380.     ss = sysSuspend
  3381.     syssuspend = false
  3382.     bref = book (mydir&"tmplhelp.tbk")
  3383.     syssuspend = ss
  3384.     if sysErrorNumber is not 0
  3385.         request "Cannot find book TMPLHELP.TBK"
  3386.     else
  3387.         vref = viewer "help" of bref
  3388.         set defaultpage of vref to page "cbt1" of bref
  3389.         open vref
  3390.         show vref
  3391.     sysErrorNumber = sen
  3392.     sysError = se
  3393. to handle initPage
  3394. to handle newChapter promptForName
  3395.     get chapterCount of this book
  3396.     if it < chapterLimit()
  3397.         if promptForName is null
  3398.             promptForName = true
  3399.         end
  3400.         chapterName = "Untitled"
  3401.         if promptForName
  3402.             ask "Enter new chapter name." with chapterName
  3403.             if syserror = cancel
  3404.                 break
  3405.             end
  3406.             chapterName = it
  3407.         end
  3408.         in mainwindow
  3409.             ls = lockscreen of this window
  3410.             lockscreen of this window = true
  3411.             -- go to a clean page so that leavePage messages are sent
  3412.             -- then suspend messages and navigate to the last page of the 
  3413.             -- appropriate background so that enterPage messages are not sent
  3414.             go to page 1
  3415.             ssm = syssuspendmessages
  3416.             syssuspendmessages = true
  3417.             go to last page of chaptersBackground()
  3418.             send newPage
  3419.             syssuspendmessages = ssm
  3420.             set label of this page to chapterName
  3421.             lastPage = max(pagenumber of last page of chaptersBackground(),\
  3422.                            pagenumber of last page of topicsBackground())
  3423.             set pageNumber of this page to lastPage
  3424.             send rebuildStructure
  3425.             send enterPage to this page
  3426.             set enabled of button "tableOfContents" of page "toolbar" to true
  3427.             lockscreen of this window = ls
  3428.         end
  3429.     else
  3430.         request "This template is limited to" && chapterLimit() && "chapters."
  3431. to handle newTopic pageNum
  3432.     chapterName = "Untitled"
  3433.     if pageNum is null
  3434.         ask "Enter new topic name." with chapterName
  3435.         if syserror = cancel
  3436.             break
  3437.         end
  3438.         chapterName = it
  3439.     in mainWindow
  3440.         if pageNum is null
  3441.             conditions
  3442.                 when this background is chaptersBackground()
  3443.                 when this background is topicsBackground()
  3444.                     pageNum = pageNumber of this page
  3445.             else
  3446.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  3447.                                pagenumber of last page of topicsBackground())
  3448.                 pageNum = lastPage
  3449.             end
  3450.         end
  3451.         ls = lockscreen of this window
  3452.         lockscreen of this window = true
  3453.         -- go to a clean page so that leavePage messages are sent
  3454.         -- then suspend messages and navigate to the last page of the 
  3455.         -- appropriate background so that enterPage messages are not sent
  3456.         go to page 1
  3457.         ssm = syssuspendmessages
  3458.         syssuspendmessages = true
  3459.         if this background is not topicsBackground()
  3460.             go to last page of topicsBackground()
  3461.         end
  3462.         send newPage
  3463.         syssuspendmessages = ssm
  3464.         set label of this page to chapterName
  3465.         set pageNumber of this page to pageNum+1
  3466.         send rebuildStructure
  3467.         send enterPage to this page
  3468.         set enabled of button "tableOfContents" of page "toolbar" to true
  3469.         lockscreen of this window = ls
  3470. to handle changeName
  3471.     ask "Enter new name." with label of this page
  3472.     if syserror = cancel
  3473.         break
  3474.     label of this page = it
  3475.     send rebuildStructure
  3476. to handle saveAs
  3477.     firstTime of this book = true
  3478.     forward
  3479. to handle aboutAnimate
  3480.     show viewer "about" as modal
  3481. to get animSysbookLoaded
  3482.     if sysbooks contains "mtb30.sbk" or sysbooks contains "mtb30anm.sbk"
  3483.         return true
  3484.     else
  3485.         return false
  3486. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3487. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3488. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3489. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3490. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3491. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3492. |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||k
  3493. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3494. O O E O 
  3495. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3496.   E E O
  3497. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3498.  : + EO
  3499. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3500. !   :+
  3501. ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  3502. |||||||
  3503. CBT_DEMO.TBK
  3504. H)H)--
  3505. --   Copyright 
  3506.  1994  Asymetrix Corporation                      
  3507. --                                                                     
  3508. --   Asymetrix gives you permission to copy, revise, and reuse the     
  3509. --   individual objects and scripts in this application in your own    
  3510. --   applications.  You may not copy the entire book (or a             
  3511. --   substantial part of it) for redistribution as your own product.   
  3512. --                                                                     
  3513. --   Asymetrix retains the copyright on the original elements of this   
  3514. --   application. Include the notice "Portions of this application are 
  3515. --   the copyright of Asymetrix Corporation" in your product if they   
  3516. --   contain objects or scripts copied from this application.          
  3517. --   Author: Joseph Brick                                              
  3518. --   Last revision: 5/9/94
  3519. to handle enterApplication
  3520.     forward
  3521.     sysHistoryRecord = true
  3522.     go to page "introscreen"
  3523.     if sysRuntime is false
  3524.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  3525.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  3526.          "Displays/hides Template Outline palette."
  3527.         add menuitem "" to menu "contents" at author
  3528.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  3529.          "Adds new chapter to this book."
  3530.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  3531.          "Changes name of current chapter."
  3532.         add menuitem "" to menu "contents" at author
  3533.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  3534.          "Adds new topic to this chapter."
  3535.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  3536.          "Changes name of topic chapter."
  3537.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  3538.          "Displays help on using this template."
  3539.         if firstTime of this book is not false
  3540.             open viewer "outline"
  3541.             send rebuildStructure
  3542.             firstTime of this book = false
  3543.         end
  3544.     send reader
  3545. to handle entermenu menuName,menuAlias
  3546.     if menuName is "contents" and syslevel is author
  3547.         if this background is chaptersBackground() 
  3548.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  3549.         else
  3550.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  3551.         end
  3552.         if this background is TopicsBackground() 
  3553.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  3554.         else
  3555.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  3556.         end
  3557.         if visible of viewer "outline"
  3558.             check menuitem "outline"  in menu "contents" at author
  3559.         else
  3560.             uncheck menuitem "outline"  in menu "contents" at author
  3561.         end
  3562.     forward
  3563. to handle leaveapplication
  3564.     set syslockscreen to true
  3565.     set captionBar of mainwindow to normal
  3566.     set state of mainwindow to normal
  3567.     remove menu "Contents" at author
  3568.     remove menuitem "helpTemplate" in menu "help" at author
  3569.     forward
  3570. to handle author
  3571.     if isOpen of viewer "outline"
  3572.         set fw to focusWindow
  3573.         show viewer "outline"
  3574.         set focusWindow to fw
  3575.     set state of mainwindow to normal
  3576.     set captionBar of mainwindow to normal
  3577.     forward
  3578. to handle reader
  3579.     forward
  3580.     if isOpen of viewer "outline"
  3581.         hide viewer "outline"
  3582.     set captionBar of mainwindow to none
  3583.     set state of mainwindow to maximized
  3584. to handle outline
  3585.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  3586.     if mstate is true
  3587.         if isOpen of viewer "outline"
  3588.             close viewer "outline"
  3589.         end
  3590.     else
  3591.         open viewer "outline"
  3592.         send rebuildStructure
  3593.         show viewer "outline"
  3594. -- if a newbackground is inserted into the content area,
  3595. -- move it beyond the content area
  3596. to handle newBackground
  3597.     forward
  3598.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  3599.                    pagenumber of last page of topicsBackground())
  3600.     if pagenumber of this page < lastPage
  3601.         pageNumber of this page = lastPage
  3602. --================ Utility handlers ===================
  3603. -- returns the background reference for the chapter headings background
  3604. to get chaptersBackground
  3605.     return background "chapterheadings"
  3606. -- returns the background reference for the chapter topics background
  3607. to get topicsBackground
  3608.     return background "content"
  3609. to handle rebuildStructure updatePalette
  3610.     local chapterCounter
  3611.     chapterCounter = 0
  3612.     if updatePalette is null
  3613.         updatePalette = true
  3614.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  3615.     pageNumber of page "introscreen" = 1
  3616.     pagenumber of first page of chaptersBackground() = 2
  3617.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  3618.                    pagenumber of last page of topicsBackground())
  3619.     pageCounter = 2
  3620.     while pageCounter <= lastPage
  3621.         curPage = page pageCounter
  3622.         curPageId = idnumber of curPage
  3623.         curBackground = parent of curPage
  3624.         pagelabel = label of curPage
  3625.         conditions
  3626.             when curBackground is chaptersBackground()
  3627.                 increment chapterCounter
  3628.                 if prevChapterHeadingPage is not NULL
  3629.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  3630.                     clear pagesOfEachChapter
  3631.                 end
  3632.                 prevChapterHeadingPage = curPage
  3633.                 curChapterId = curPageId
  3634.                 myChapterID of curPage = curChapterID
  3635.                 if chapterList is not null
  3636.                     put crlf after chapterList
  3637.                 end
  3638.                 put curPageId & "," & pageLabel after chapterList
  3639.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  3640.                 increment pageCounter
  3641.             when curBackground is topicsBackground()
  3642.                 chapter of curPage = chapterCounter
  3643.                 if pagesOfEachChapter is not null
  3644.                     put "," after pagesOfEachChapter
  3645.                 end
  3646.                 put idnumber of curPage after pagesOfEachChapter
  3647.                 myChapterID of curPage = curChapterID
  3648.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  3649.                 increment pageCounter
  3650.         else
  3651.             -- this page is not of either background. Move it beyond both backgrounds
  3652.             pageNumber of curPage = lastPage
  3653.             decrement lastPage    
  3654.         end
  3655.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  3656.     voutline of group "tableOfContents" of background "Content" = chapterList
  3657.     clear last char of listBoxText
  3658.     clear last char of listBoxText
  3659.     if updatePalette
  3660.         if isOpen of viewer "outline"
  3661.             send initPage listBoxText to currentPage of viewer "outline"
  3662.             in mainWindow
  3663.                 send enterpage to this page
  3664.             end
  3665.         end
  3666. -- Used to get the text before a tab of a textline
  3667. -- (in the list box of a dialog viewer, tab is used 
  3668. -- to store extra information that gets clipped by the 
  3669. -- right side of the field)
  3670. to get extractName t
  3671.     if first char of t is tab
  3672.         clear first char of t
  3673.     tabOffset = offset(tab,t)
  3674.     if tabOffset is 0
  3675.         return null
  3676.     else
  3677.         return chars 1 to tabOffset-1 of t
  3678. -- Used to get the text beyond a tab of a textline
  3679. to get extractID t
  3680.     lastTabLoc = charcount(t)
  3681.         decrement lastTabLoc
  3682.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  3683.     if lastTabLoc <=0
  3684.         return null
  3685.     else
  3686.         return chars lastTabLoc+1 to charcount(t) of t
  3687. -- returns the numerical location of an item in a list
  3688. to get itemOffset itm,lst
  3689.     step i from 1 to itemcount(lst)
  3690.         pop lst
  3691.         if it = itm
  3692.             return i
  3693.         end
  3694.     return 0
  3695. -- returns a gray color
  3696. to get middleGray
  3697.     return 240,63.5,2.1875
  3698. -- returns dark blue
  3699. to get darkBlue
  3700.     return 240,25.125,100
  3701. -- returns a string of tabs. This serves a spacer between the 
  3702. -- label of a page and the idnumber on each line in the listbox. 
  3703. -- This is used so the idnumber is clipped and not visible
  3704. to get tabSpacer
  3705.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  3706. to handle helpTemplate
  3707.     mydir = name of self
  3708.         clear last char of mydir
  3709.     until last char of mydir is "\" or mydir is null
  3710.     sen = sysErrorNumber
  3711.     se = sysError
  3712.     sysErrorNumber = 0
  3713.     ss = sysSuspend
  3714.     syssuspend = false
  3715.     bref = book (mydir&"tmplhelp.tbk")
  3716.     syssuspend = ss
  3717.     if sysErrorNumber is not 0
  3718.         request "Cannot find book TMPLHELP.TBK"
  3719.     else
  3720.         vref = viewer "help" of bref
  3721.         set defaultpage of vref to page "cbt1" of bref
  3722.         open vref
  3723.         show vref
  3724.     sysErrorNumber = sen
  3725.     sysError = se
  3726. to handle initPage
  3727. to handle newChapter promptForName
  3728.     if promptForName is null
  3729.         promptForName = true
  3730.     chapterName = "Untitled"
  3731.     if promptForName
  3732.         ask "Enter new chapter name." with chapterName
  3733.         if syserror = cancel
  3734.             break
  3735.         end
  3736.         chapterName = it
  3737.     in mainwindow
  3738.         ls = lockscreen of this window
  3739.         lockscreen of this window = true
  3740.         go to last page of chaptersBackground()
  3741.         ssm = syssuspendmessages
  3742.         syssuspendmessages = true
  3743.         send newPage
  3744.         syssuspendmessages = ssm
  3745.         set label of this page to chapterName
  3746.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  3747.                        pagenumber of last page of topicsBackground())
  3748.         set pageNumber of this page to lastPage
  3749.         send rebuildStructure
  3750.         send enterPage to this page
  3751.         lockscreen of this window = ls
  3752. to handle newTopic pageNum
  3753.     chapterName = "Untitled"
  3754.     if pageNum is null
  3755.         ask "Enter new topic name." with chapterName
  3756.         if syserror = cancel
  3757.             break
  3758.         end
  3759.         chapterName = it
  3760.     in mainWindow
  3761.         if pageNum is null
  3762.             conditions
  3763.                 when this background is chaptersBackground()
  3764.                 when this background is topicsBackground()
  3765.                     pageNum = pageNumber of this page
  3766.             else
  3767.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  3768.                                pagenumber of last page of topicsBackground())
  3769.                 pageNum = lastPage
  3770.             end
  3771.         end
  3772.         ls = lockscreen of this window
  3773.         lockscreen of this window = true
  3774.         if this background is not topicsBackground()
  3775.             go to last page of topicsBackground()
  3776.         end
  3777.         ssm = syssuspendmessages
  3778.         syssuspendmessages = true
  3779.         send newPage
  3780.         syssuspendmessages = ssm
  3781.         set label of this page to chapterName
  3782.         set pageNumber of this page to pageNum+1
  3783.         send rebuildStructure
  3784.         send enterPage to this page
  3785.         lockscreen of this window = ls
  3786. to handle changeName
  3787.     ask "Enter new name." with label of this page
  3788.     if syserror = cancel
  3789.         break
  3790.     label of this page = it
  3791.     send rebuildStructure
  3792. to handle sizeToPage
  3793.     if syslevel is AUTHOR
  3794.         forward
  3795. CBT_TIPS.TBK
  3796. --==================== Standard ToolBook messages ===================
  3797. to handle enterApplication
  3798.     forward
  3799.     -- link needed dll's
  3800.     linkDLL "tb30win.dll"
  3801.         int displayBitsPerPixel()
  3802.     -- these gdi calls are used for drawing separator line
  3803.     linkDLL "gdi"
  3804.         int getDeviceCaps(word,int)
  3805.         dword moveTo(word,int,int)
  3806.         int lineTo(word,int,int)
  3807.         int setROP2(word,int)
  3808.         word createPen(int,int,dword)
  3809.         int deleteObject(word)
  3810.         word selectObject(word,word)
  3811.     linkdll user
  3812.         word getDC(word)
  3813.         int releaseDC(word,word)
  3814.     if sysruntime is false
  3815.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  3816.          "Displays help on using this template."
  3817.     -- set backcolor (a "to set" handler, below) depending on
  3818.     -- the number of colors displayed.
  3819.     get numColors()
  3820.     if it > 16 or it = 0
  3821.         set backcolor of this book to darkerBlue()
  3822.     else
  3823.         set backcolor of this book to lighterBlue()
  3824.     show viewer "navigationBar"
  3825.     in viewer "navigationBar"
  3826.         -- initialize combobox and field in navigation window
  3827.         set text of combobox "categories" to "<All topics>"
  3828.         send populate "All" to field "Topics"
  3829.     if sysLevel is not "reader"
  3830.         send reader
  3831.     else
  3832.         send hideControls
  3833. to handle leaveApplication
  3834.     remove menuitem "helpTemplate" in menu "help" at author
  3835. -- show buttons for modifying book
  3836. to handle author
  3837.     forward
  3838.     send showControls
  3839. to handle showControls
  3840.     show group "CategoryButtons" of page "Navigation"
  3841.     set item 4 of bounds of field "topics" of page "Navigation" to \
  3842.      item 2 of bounds of group "CategoryButtons" of page "Navigation" - 60
  3843.     send sizetopage
  3844. -- hide buttons for modifying book
  3845. to handle reader
  3846.     forward
  3847.     send hideControls
  3848. to handle hideControls
  3849.     hide group "CategoryButtons" of page "Navigation"
  3850.     set item 4 of bounds of field "topics" of page "Navigation" to \
  3851.      item 4 of bounds of group "CategoryButtons" of page "Navigation"
  3852.     send sizetopage
  3853. to handle destroy
  3854.     -- if a page is deleted, updates the category array (struct[][]) userProperty 
  3855.     -- of this book.
  3856.     -- Each row of the category array has the category name and a list
  3857.     -- of the id numbers of pages belonging to that category. This handler
  3858.     -- walks through the array, finding every instance of that id number.
  3859.     -- when found, it removes it.
  3860.     if object of target is "page" and name of parent of target is in "description and script,description and example,description only"
  3861.         local x[][]
  3862.         set x to categoryStruct of this book
  3863.         set pageID to idnumber of target
  3864.         step i from 1 to item 1 of dimensions(x)
  3865.             get itemOffset(pageID,x[i][2])
  3866.             if it > 0
  3867.                 clear item it of x[i][2]
  3868.             end
  3869.         end
  3870.         set categoryStruct of this book to x
  3871.     forward
  3872. to handle enterPage
  3873.     forward
  3874.     -- if this is a content background
  3875.     if name of parent of this page is in "description and script,description and example,description only"
  3876.         -- to ensure the recordfield is set to the label property
  3877.         -- the label property holds the name of each topic
  3878.         set fref to recordfield "subTopicName" of this page
  3879.         if text of fref is not label of this page
  3880.             set text of fref to label of this page
  3881.         end
  3882.         -- set the scroll of the recordfield, if necessary
  3883.         set fref to recordfield "explanation"
  3884.         if scroll of fref is not 0
  3885.             set scroll of fref to 0
  3886.         end
  3887.         -- add/remove scrollbars, if necessary
  3888.         set txtOver to textoverflow of fref
  3889.         conditions
  3890.             when txtOver > 0 and borderstyle of fref is "none"
  3891.                 set borderstyle of fref to "scrolling"
  3892.             when txtOver = 0 and borderstyle of fref is "scrolling"
  3893.                 set borderstyle of fref to "none"
  3894.         end
  3895. to handle leavePage
  3896.     forward
  3897.     if name of parent of this page is in "description and script,description and example,description only"
  3898.         set topic to text of recordfield "subTopicName"
  3899.         if label of this page is not topic
  3900.             set label of this page to topic
  3901.         end
  3902. --========================= Utility handlers ===========================
  3903. -- returns the text before a tab
  3904. to get extractName t
  3905.     set tabOffset to offset(tab,t)
  3906.     return chars 1 to tabOffset-1 of t
  3907. -- returns the text following a tab
  3908. to get extractID t
  3909.     set lastTabLoc to charcount(t)
  3910.         decrement lastTabLoc
  3911.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  3912.     if lastTabLoc <=0
  3913.         return null
  3914.     else
  3915.         return chars lastTabLoc+1 to charcount(t) of t
  3916. -- returns the offset of item itm in list lst
  3917. to get itemOffset itm,lst
  3918.     step i from 1 to itemcount(lst)
  3919.         pop lst
  3920.         if itm = it
  3921.             return i
  3922.         end
  3923.     return 0
  3924. -- removes all instances of a char from a string
  3925. to get stripChar chr,strng
  3926.     while strng contains chr
  3927.         clear char offset(chr,strng) of strng
  3928.     return strng
  3929. -- returns the number of colors displayed
  3930. to get numColors
  3931.     hdc = getDC(windowhandle of mainWindow)
  3932.     retval = getDeviceCaps(hdc,24)
  3933.     get releaseDC(windowhandle of mainwindow,hdc)
  3934.     return retval
  3935. to get darkerBlue
  3936.     return 212,79.1875,71.6875
  3937. to get lighterBlue
  3938.     return 180,75.125,100
  3939. to set backColor to value
  3940.     set bckgrnds to "intro,description and script,description and example,description only"
  3941.     step i from 1 to itemcount(bckgrnds)
  3942.         pop bckgrnds
  3943.         set curBack to background it
  3944.         if fillcolor of curBack is not value
  3945.             set fillcolor of curBack to value
  3946.         end
  3947. --================ Handlers for dealing with array structure ============
  3948. -- display the array in a request box.
  3949. -- (used during authoring for debugging purposes)
  3950. to handle showCategoryStruct
  3951.     local x[][]
  3952.     set x to categoryStruct of this book
  3953.     local retval
  3954.     step i from 1 to item 1 of dimensions(x)
  3955.         put x[i][1] after retval
  3956.         put tab & x[i][2] & crlf after retval
  3957.     request retval
  3958. --------------- these handers sort the array --------------------
  3959. to handle twoDquicksort fArray[][],n,dtype
  3960.     system stbk_noSwap
  3961.     set stbk_noSwap to 0
  3962.     send twoDquicksrt fArray, 1, item 1 of dimensions(fArray),n,dtype
  3963. to handle twoDquicksrt fArray[][], l, r,n,dtype
  3964.     system  stbk_noSwap
  3965.     if r > l 
  3966.         send swap  fArray, l, ((l+r) div 2)
  3967.         set lst to l
  3968.         step i from (l+1) to r
  3969.             conditions
  3970.                 when dtype is "text"
  3971.                     set test to fArray[i][n] < fArray[l][n] as text
  3972.                 when dtype is "date"
  3973.                     set test to fArray[i][n] < fArray[l][n] as date
  3974.                 else
  3975.                     set test to fArray[i][n] < fArray[l][n] as number
  3976.             end
  3977.             if test
  3978.                 increment lst
  3979.                 send swap fArray, lst, i
  3980.             else
  3981.                 increment stbk_noswap
  3982.             end if
  3983.         end step
  3984.         send swap fArray,l,lst 
  3985.            
  3986.            send twoDquicksrt fArray, l, lst-1,n,dtype
  3987.         send twoDquicksrt fArray, lst+1,r,n,dtype
  3988.        end
  3989. to handle swap fArray[][], a, b
  3990.     local temp
  3991.     step i from 1 to item 2 of dimensions (fArray)
  3992.         set temp to farray[a][i]
  3993.         set farray[a][i] to farray[b][i]
  3994.         set farray[b][i] to temp
  3995. to handle helpTemplate
  3996.     mydir = name of self
  3997.         clear last char of mydir
  3998.     until last char of mydir is "\" or mydir is null
  3999.     sen = sysErrorNumber
  4000.     se = sysError
  4001.     sysErrorNumber = 0
  4002.     ss = sysSuspend
  4003.     syssuspend = false
  4004.     bref = book (mydir&"tmplhelp.tbk")
  4005.     syssuspend = ss
  4006.     if sysErrorNumber is not 0
  4007.         request "Cannot find book TMPLHELP.TBK"
  4008.     else
  4009.         vref = viewer "help" of bref
  4010.         set defaultpage of vref to page "cbt4" of bref
  4011.         open vref
  4012.         show vref
  4013.     sysErrorNumber = sen
  4014.     sysError = se
  4015. CBT1.TBK
  4016. --   Copyright 
  4017.  1994  Asymetrix Corporation                      
  4018. --                                                                     
  4019. --   Asymetrix gives you permission to copy, revise, and reuse the     
  4020. --   individual objects and scripts in this application in your own    
  4021. --   applications.  You may not copy the entire book (or a             
  4022. --   substantial part of it) for redistribution as your own product.   
  4023. --                                                                     
  4024. --   Asymetrix retains the copyright on the original elements of this   
  4025. --   application. Include the notice "Portions of this application are 
  4026. --   the copyright of Asymetrix Corporation" in your product if they   
  4027. --   contain objects or scripts copied from this application.          
  4028. --   Author: Joseph Brick                                              
  4029. --   Last revision: 5/9/94
  4030. --============== Standard ToolBook messages ===================
  4031. -- set up the menus, initialize Back handling
  4032. to handle enterApplication
  4033.     forward
  4034.     set enabled of button "back" of page "toolbar" to false
  4035.     if sysRuntime is false
  4036.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  4037.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  4038.          "Displays/hides Template Outline palette."
  4039.         add menuitem "" to menu "contents" at author
  4040.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  4041.          "Adds new chapter to this book."
  4042.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  4043.          "Changes name of current chapter."
  4044.         add menuitem "" to menu "contents" at author
  4045.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  4046.          "Adds new topic to this chapter."
  4047.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  4048.          "Changes name of topic chapter."
  4049.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  4050.          "Displays help on using this template."
  4051.         if firstTime of this book is not false
  4052.             open viewer "outline"
  4053.             send rebuildStructure
  4054.             firstTime of this book = false
  4055.         end
  4056.     hide button "help" of page "toolbar"
  4057.     -- initialize checkmarks
  4058.     bk = topicsBackground()
  4059.     step i from 1 to pagecount of bk
  4060.         set visited of page i of bk to false
  4061.     set checked of group "tableofcontents" of page "tableOfContents" to false
  4062.     if syslevel is author
  4063.         send reader
  4064. to handle entermenu menuName,menuAlias
  4065.     if menuName is "contents" and syslevel is author
  4066.         if this background is chaptersBackground() 
  4067.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  4068.         else
  4069.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  4070.         end
  4071.         if this background is TopicsBackground() 
  4072.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  4073.         else
  4074.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  4075.         end
  4076.         if visible of viewer "outline"
  4077.             check menuitem "outline"  in menu "contents" at author
  4078.         else
  4079.             uncheck menuitem "outline"  in menu "contents" at author
  4080.         end
  4081.     forward
  4082. to handle leaveapplication
  4083.     remove menu "Contents" at author
  4084.     remove menuitem "helpTemplate" in menu "help" at author
  4085.     forward
  4086. to handle author
  4087.     if isOpen of viewer "outline"
  4088.         set fw to focusWindow
  4089.         show viewer "outline"
  4090.         set focusWindow to fw
  4091.     show button "help" of page "toolbar"
  4092.     forward
  4093. to handle reader
  4094.     forward
  4095.     if isOpen of viewer "outline"
  4096.         hide viewer "outline"
  4097.     hide button "help" of page "toolbar"
  4098. to handle outline
  4099.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  4100.     if mstate is true
  4101.         if isOpen of viewer "outline"
  4102.             close viewer "outline"
  4103.         end
  4104.     else
  4105.         open viewer "outline"
  4106.         send rebuildStructure
  4107.         show viewer "outline"
  4108. -- if a newbackground is inserted into the content area,
  4109. -- move it beyond the content area
  4110. to handle newBackground
  4111.     forward
  4112.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  4113.                    pagenumber of last page of topicsBackground())
  4114.     if pagenumber of this page < lastPage
  4115.         pageNumber of this page = lastPage
  4116. --================ Utility handlers ===================
  4117. -- returns the background reference for the chapter headings background
  4118. to get chaptersBackground
  4119.     return background "chapter headings"
  4120. -- returns the background reference for the chapter topics background
  4121. to get topicsBackground
  4122.     return background "topics"
  4123. to handle rebuildStructure updatePalette
  4124.     if updatePalette is null
  4125.         updatePalette = true
  4126.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  4127.     pageNumber of page "tableofcontents" = 1
  4128.     pagenumber of first page of chaptersBackground() = 2
  4129.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  4130.                    pagenumber of last page of topicsBackground())
  4131.     pageCounter = 2
  4132.     while pageCounter <= lastPage
  4133.         curPage = page pageCounter
  4134.         curPageId = idnumber of curPage
  4135.         curBackground = parent of curPage
  4136.         pagelabel = label of curPage
  4137.         conditions
  4138.             when curBackground is chaptersBackground()
  4139.                 if prevChapterHeadingPage is not NULL
  4140.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  4141.                     clear pagesOfEachChapter
  4142.                 end
  4143.                 prevChapterHeadingPage = curPage
  4144.                 curChapterId = curPageId
  4145.                 myChapterID of curPage = curChapterID
  4146.                 if chapterList is not null
  4147.                     put crlf after chapterList
  4148.                 end
  4149.                 put curPageId & "," & pageLabel after chapterList
  4150.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  4151.                 increment pageCounter
  4152.             when curBackground is topicsBackground()
  4153.                 if pagesOfEachChapter is not null
  4154.                     put "," after pagesOfEachChapter
  4155.                 end
  4156.                 put idnumber of curPage after pagesOfEachChapter
  4157.                 myChapterID of curPage = curChapterID
  4158.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  4159.                 increment pageCounter
  4160.         else
  4161.             -- this page is not of either background. Move it beyond both backgrounds
  4162.             pageNumber of curPage = lastPage
  4163.             decrement lastPage    
  4164.         end
  4165.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  4166.     voutline of group "tableOfContents" of page "tableOfContents" = chapterList
  4167.     clear last char of listBoxText
  4168.     clear last char of listBoxText
  4169.     if updatePalette
  4170.         if isOpen of viewer "outline"
  4171.             send initPage listBoxText to currentPage of viewer "outline"
  4172.         end
  4173.     in mainWindow
  4174.         send initPage to this page
  4175. -- Used to get the text before a tab of a textline
  4176. -- (in the list box of a dialog viewer, tab is used 
  4177. -- to store extra information that gets clipped by the 
  4178. -- right side of the field)
  4179. to get extractName t
  4180.     if first char of t is tab
  4181.         clear first char of t
  4182.     tabOffset = offset(tab,t)
  4183.     if tabOffset is 0
  4184.         return null
  4185.     else
  4186.         return chars 1 to tabOffset-1 of t
  4187. -- Used to get the text beyond a tab of a textline
  4188. to get extractID t
  4189.     lastTabLoc = charcount(t)
  4190.         decrement lastTabLoc
  4191.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  4192.     if lastTabLoc <=0
  4193.         return null
  4194.     else
  4195.         return chars lastTabLoc+1 to charcount(t) of t
  4196. -- returns the numerical location of an item in a list
  4197. to get itemOffset itm,lst
  4198.     step i from 1 to itemcount(lst)
  4199.         pop lst
  4200.         if it = itm
  4201.             return i
  4202.         end
  4203.     return 0
  4204. -- returns a gray color
  4205. to get middleGray
  4206.     return 240,63.5,2.1875
  4207. -- returns dark blue
  4208. to get darkBlue
  4209.     return 240,25.125,100
  4210. -- returns a string of tabs. This serves a spacer between the 
  4211. -- label of a page and the idnumber on each line in the listbox. 
  4212. -- This is used so the idnumber is clipped and not visible
  4213. to get tabSpacer
  4214.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  4215. --============= Navigation and menu messages =============
  4216. -- tableOfContents message sent by toolbar
  4217. -- when the tableOfContents button is pressed
  4218. to handle tableOfContents
  4219.     pref = page "tableOfContents"
  4220.     send updatechecks to group "tableofcontents" of pref
  4221.     go to pref
  4222. to handle helpTemplate
  4223.     mydir = name of self
  4224.         clear last char of mydir
  4225.     until last char of mydir is "\" or mydir is null
  4226.     sen = sysErrorNumber
  4227.     se = sysError
  4228.     sysErrorNumber = 0
  4229.     ss = sysSuspend
  4230.     syssuspend = false
  4231.     bref = book (mydir&"tmplhelp.tbk")
  4232.     syssuspend = ss
  4233.     if sysErrorNumber is not 0
  4234.         request "Cannot find book TMPLHELP.TBK"
  4235.     else
  4236.         vref = viewer "help" of bref
  4237.         set defaultpage of vref to page "cbt1" of bref
  4238.         open vref
  4239.         show vref
  4240.     sysErrorNumber = sen
  4241.     sysError = se
  4242. to handle initPage
  4243. to handle newChapter promptForName
  4244.     if promptForName is null
  4245.         promptForName = true
  4246.     chapterName = "Untitled"
  4247.     if promptForName
  4248.         ask "Enter new chapter name." with chapterName
  4249.         if syserror = cancel
  4250.             break
  4251.         end
  4252.         chapterName = it
  4253.     in mainwindow
  4254.         ls = lockscreen of this window
  4255.         lockscreen of this window = true
  4256.         go to last page of chaptersBackground()
  4257.         ssm = syssuspendmessages
  4258.         syssuspendmessages = true
  4259.         send newPage
  4260.         syssuspendmessages = ssm
  4261.         set label of this page to chapterName
  4262.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  4263.                        pagenumber of last page of topicsBackground())
  4264.         set pageNumber of this page to lastPage
  4265.         send rebuildStructure
  4266.         send enterPage to this page
  4267.         lockscreen of this window = ls
  4268. to handle newTopic pageNum
  4269.     chapterName = "Untitled"
  4270.     if pageNum is null
  4271.         ask "Enter new topic name." with chapterName
  4272.         if syserror = cancel
  4273.             break
  4274.         end
  4275.         chapterName = it
  4276.     in mainWindow
  4277.         if pageNum is null
  4278.             conditions
  4279.                 when this background is chaptersBackground()
  4280.                 when this background is topicsBackground()
  4281.                     pageNum = pageNumber of this page
  4282.             else
  4283.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  4284.                                pagenumber of last page of topicsBackground())
  4285.                 pageNum = lastPage
  4286.             end
  4287.         end
  4288.         ls = lockscreen of this window
  4289.         lockscreen of this window = true
  4290.         if this background is not topicsBackground()
  4291.             go to last page of topicsBackground()
  4292.         end
  4293.         ssm = syssuspendmessages
  4294.         syssuspendmessages = true
  4295.         send newPage
  4296.         syssuspendmessages = ssm
  4297.         set label of this page to chapterName
  4298.         set pageNumber of this page to pageNum+1
  4299.         send rebuildStructure
  4300.         send enterPage to this page
  4301.         lockscreen of this window = ls
  4302. to handle changeName
  4303.     ask "Enter new name." with label of this page
  4304.     if syserror = cancel
  4305.         break
  4306.     label of this page = it
  4307.     send rebuildStructure
  4308. CBT2.TBK
  4309. --   Copyright 
  4310.  1994  Asymetrix Corporation                      
  4311. --                                                                     
  4312. --   Asymetrix gives you permission to copy, revise, and reuse the     
  4313. --   individual objects and scripts in this application in your own    
  4314. --   applications.  You may not copy the entire book (or a             
  4315. --   substantial part of it) for redistribution as your own product.   
  4316. --                                                                     
  4317. --   Asymetrix retains the copyright on the original elements of this   
  4318. --   application. Include the notice "Portions of this application are 
  4319. --   the copyright of Asymetrix Corporation" in your product if they   
  4320. --   contain objects or scripts copied from this application.          
  4321. --   Author: Joseph Brick                                              
  4322. --   Last revision: 5/9/94
  4323. to handle enterApplication
  4324.     forward
  4325.     go to page "introscreen"
  4326.     if sysRuntime is false
  4327.         add menu "&Contents" at author with helpText "Options for modifying content of this template."
  4328.         add menuitem "Template &Outline" alias "outline" to menu "contents" at author with helptext\
  4329.          "Displays/hides Template Outline palette."
  4330.         add menuitem "" to menu "contents" at author
  4331.         add menuitem "New &Chapter..." to menu "contents" at author with helptext\
  4332.          "Adds new chapter to this book."
  4333.         add menuitem "Change C&hapter Name.." alias "changeName" to menu "contents" at author with helptext\
  4334.          "Changes name of current chapter."
  4335.         add menuitem "" to menu "contents" at author
  4336.         add menuitem "New &Topic..." to menu "contents" at author with helptext\
  4337.          "Adds new topic to this chapter."
  4338.         add menuitem "Change To&pic Name.."  alias "changeName" to menu "contents" at author with helptext\
  4339.          "Changes name of topic chapter."
  4340.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  4341.          "Displays help on using this template."
  4342.         if firstTime of this book is not false
  4343.             open viewer "outline"
  4344.             send rebuildStructure
  4345.             firstTime of this book = false
  4346.         end
  4347.     send reader
  4348. to handle entermenu menuName,menuAlias
  4349.     if menuName is "contents" and syslevel is author
  4350.         if this background is chaptersBackground() 
  4351.             enable menuitem "Change Chapter Name..." in menu "contents" at author
  4352.         else
  4353.             disable menuitem "Change Chapter Name..."  in menu "contents" at author
  4354.         end
  4355.         if this background is TopicsBackground() 
  4356.             enable menuitem "Change Topic Name..."  in menu "contents" at author
  4357.         else
  4358.             disable menuitem "Change Topic Name..."  in menu "contents" at author
  4359.         end
  4360.         if visible of viewer "outline"
  4361.             check menuitem "outline"  in menu "contents" at author
  4362.         else
  4363.             uncheck menuitem "outline"  in menu "contents" at author
  4364.         end
  4365.     forward
  4366. to handle leaveapplication
  4367.     remove menu "Contents" at author
  4368.     remove menuitem "helpTemplate" in menu "help" at author
  4369.     forward
  4370. to handle author
  4371.     if isOpen of viewer "outline"
  4372.         set fw to focusWindow
  4373.         show viewer "outline"
  4374.         set focusWindow to fw
  4375.     set state of mainwindow to normal
  4376.     set captionBar of mainwindow to normal
  4377.     forward
  4378. to handle reader
  4379.     forward
  4380.     if isOpen of viewer "outline"
  4381.         hide viewer "outline"
  4382.     set captionBar of mainwindow to none
  4383.     set state of mainwindow to maximized
  4384. to handle outline
  4385.     mstate = menuItemChecked("outline" in menu "contents" at author,mainwindow)
  4386.     if mstate is true
  4387.         if isOpen of viewer "outline"
  4388.             close viewer "outline"
  4389.         end
  4390.     else
  4391.         open viewer "outline"
  4392.         send rebuildStructure
  4393.         show viewer "outline"
  4394. -- if a newbackground is inserted into the content area,
  4395. -- move it beyond the content area
  4396. to handle newBackground
  4397.     forward
  4398.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  4399.                    pagenumber of last page of topicsBackground())
  4400.     if pagenumber of this page < lastPage
  4401.         pageNumber of this page = lastPage
  4402. --================ Utility handlers ===================
  4403. -- returns the background reference for the chapter headings background
  4404. to get chaptersBackground
  4405.     return background "chapterheadings"
  4406. -- returns the background reference for the chapter topics background
  4407. to get topicsBackground
  4408.     return background "content"
  4409. to handle rebuildStructure updatePalette
  4410.     local chapterCounter
  4411.     chapterCounter = 0
  4412.     if updatePalette is null
  4413.         updatePalette = true
  4414.     local pagesOfEachChapter,curPage,curBackground,prevChapterHeadingPage,chapterList,listBoxText
  4415.     pageNumber of page "introscreen" = 1
  4416.     pagenumber of first page of chaptersBackground() = 2
  4417.     lastPage = max(pagenumber of last page of chaptersBackground(),\
  4418.                    pagenumber of last page of topicsBackground())
  4419.     pageCounter = 2
  4420.     while pageCounter <= lastPage
  4421.         curPage = page pageCounter
  4422.         curPageId = idnumber of curPage
  4423.         curBackground = parent of curPage
  4424.         pagelabel = label of curPage
  4425.         conditions
  4426.             when curBackground is chaptersBackground()
  4427.                 increment chapterCounter
  4428.                 if prevChapterHeadingPage is not NULL
  4429.                     myPages of prevChapterHeadingPage = pagesOfEachChapter
  4430.                     clear pagesOfEachChapter
  4431.                 end
  4432.                 prevChapterHeadingPage = curPage
  4433.                 curChapterId = curPageId
  4434.                 myChapterID of curPage = curChapterID
  4435.                 if chapterList is not null
  4436.                     put crlf after chapterList
  4437.                 end
  4438.                 put curPageId & "," & pageLabel after chapterList
  4439.                 put pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  4440.                 increment pageCounter
  4441.             when curBackground is topicsBackground()
  4442.                 chapter of curPage = chapterCounter
  4443.                 if pagesOfEachChapter is not null
  4444.                     put "," after pagesOfEachChapter
  4445.                 end
  4446.                 put idnumber of curPage after pagesOfEachChapter
  4447.                 myChapterID of curPage = curChapterID
  4448.                 put tab & pageLabel & tabSpacer() & curPageId & crlf after listBoxText
  4449.                 increment pageCounter
  4450.         else
  4451.             -- this page is not of either background. Move it beyond both backgrounds
  4452.             pageNumber of curPage = lastPage
  4453.             decrement lastPage    
  4454.         end
  4455.     myPages of prevChapterHeadingPage = pagesOfEachChapter
  4456.     voutline of group "tableOfContents" of background "Content" = chapterList
  4457.     clear last char of listBoxText
  4458.     clear last char of listBoxText
  4459.     if updatePalette
  4460.         if isOpen of viewer "outline"
  4461.             send initPage listBoxText to currentPage of viewer "outline"
  4462.             in mainWindow
  4463.                 send enterpage to this page
  4464.             end
  4465.         end
  4466. -- Used to get the text before a tab of a textline
  4467. -- (in the list box of a dialog viewer, tab is used 
  4468. -- to store extra information that gets clipped by the 
  4469. -- right side of the field)
  4470. to get extractName t
  4471.     if first char of t is tab
  4472.         clear first char of t
  4473.     tabOffset = offset(tab,t)
  4474.     if tabOffset is 0
  4475.         return null
  4476.     else
  4477.         return chars 1 to tabOffset-1 of t
  4478. -- Used to get the text beyond a tab of a textline
  4479. to get extractID t
  4480.     lastTabLoc = charcount(t)
  4481.         decrement lastTabLoc
  4482.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  4483.     if lastTabLoc <=0
  4484.         return null
  4485.     else
  4486.         return chars lastTabLoc+1 to charcount(t) of t
  4487. -- returns the numerical location of an item in a list
  4488. to get itemOffset itm,lst
  4489.     step i from 1 to itemcount(lst)
  4490.         pop lst
  4491.         if it = itm
  4492.             return i
  4493.         end
  4494.     return 0
  4495. -- returns a gray color
  4496. to get middleGray
  4497.     return 240,63.5,2.1875
  4498. -- returns dark blue
  4499. to get darkBlue
  4500.     return 240,25.125,100
  4501. -- returns a string of tabs. This serves a spacer between the 
  4502. -- label of a page and the idnumber on each line in the listbox. 
  4503. -- This is used so the idnumber is clipped and not visible
  4504. to get tabSpacer
  4505.     return tab&tab&tab&tab&tab&tab&tab&tab&tab&tab
  4506. to handle helpTemplate
  4507.     mydir = name of self
  4508.         clear last char of mydir
  4509.     until last char of mydir is "\" or mydir is null
  4510.     sen = sysErrorNumber
  4511.     se = sysError
  4512.     sysErrorNumber = 0
  4513.     ss = sysSuspend
  4514.     syssuspend = false
  4515.     bref = book (mydir&"tmplhelp.tbk")
  4516.     syssuspend = ss
  4517.     if sysErrorNumber is not 0
  4518.         request "Cannot find book TMPLHELP.TBK"
  4519.     else
  4520.         vref = viewer "help" of bref
  4521.         set defaultpage of vref to page "cbt1" of bref
  4522.         open vref
  4523.         show vref
  4524.     sysErrorNumber = sen
  4525.     sysError = se
  4526. to handle initPage
  4527. to handle newChapter promptForName
  4528.     if promptForName is null
  4529.         promptForName = true
  4530.     chapterName = "Untitled"
  4531.     if promptForName
  4532.         ask "Enter new chapter name." with chapterName
  4533.         if syserror = cancel
  4534.             break
  4535.         end
  4536.         chapterName = it
  4537.     in mainwindow
  4538.         ls = lockscreen of this window
  4539.         lockscreen of this window = true
  4540.         go to last page of chaptersBackground()
  4541.         ssm = syssuspendmessages
  4542.         syssuspendmessages = true
  4543.         send newPage
  4544.         syssuspendmessages = ssm
  4545.         set label of this page to chapterName
  4546.         lastPage = max(pagenumber of last page of chaptersBackground(),\
  4547.                        pagenumber of last page of topicsBackground())
  4548.         set pageNumber of this page to lastPage
  4549.         send rebuildStructure
  4550.         send enterPage to this page
  4551.         lockscreen of this window = ls
  4552. to handle newTopic pageNum
  4553.     chapterName = "Untitled"
  4554.     if pageNum is null
  4555.         ask "Enter new topic name." with chapterName
  4556.         if syserror = cancel
  4557.             break
  4558.         end
  4559.         chapterName = it
  4560.     in mainWindow
  4561.         if pageNum is null
  4562.             conditions
  4563.                 when this background is chaptersBackground()
  4564.                 when this background is topicsBackground()
  4565.                     pageNum = pageNumber of this page
  4566.             else
  4567.                 lastPage = max(pagenumber of last page of chaptersBackground(),\
  4568.                                pagenumber of last page of topicsBackground())
  4569.                 pageNum = lastPage
  4570.             end
  4571.         end
  4572.         ls = lockscreen of this window
  4573.         lockscreen of this window = true
  4574.         if this background is not topicsBackground()
  4575.             go to last page of topicsBackground()
  4576.         end
  4577.         ssm = syssuspendmessages
  4578.         syssuspendmessages = true
  4579.         send newPage
  4580.         syssuspendmessages = ssm
  4581.         set label of this page to chapterName
  4582.         set pageNumber of this page to pageNum+1
  4583.         send rebuildStructure
  4584.         send enterPage to this page
  4585.         lockscreen of this window = ls
  4586. to handle changeName
  4587.     ask "Enter new name." with label of this page
  4588.     if syserror = cancel
  4589.         break
  4590.     label of this page = it
  4591.     send rebuildStructure
  4592. to handle sizeToPage
  4593.     if syslevel is AUTHOR
  4594.         forward
  4595. to handle exit
  4596.     syserror = null
  4597.     forward
  4598.     if syserror is null
  4599.         set syslockscreen to true
  4600.         set captionBar of mainwindow to normal
  4601.         set state of mainwindow to normal
  4602. CBT4.TBK
  4603. --==================== Standard ToolBook messages ===================
  4604. to handle enterApplication
  4605.     forward
  4606.     -- link needed dll's
  4607.     linkDLL "tb30win.dll"
  4608.         int displayBitsPerPixel()
  4609.     -- these gdi calls are used for drawing separator line
  4610.     linkDLL "gdi"
  4611.         int getDeviceCaps(word,int)
  4612.         dword moveTo(word,int,int)
  4613.         int lineTo(word,int,int)
  4614.         int setROP2(word,int)
  4615.         word createPen(int,int,dword)
  4616.         int deleteObject(word)
  4617.         word selectObject(word,word)
  4618.     linkdll user
  4619.         word getDC(word)
  4620.         int releaseDC(word,word)
  4621.     if sysruntime is false
  4622.         add menuitem "Using this &Template" alias "helpTemplate" to menu "help" position 2 at author with helptext\
  4623.          "Displays help on using this template."
  4624.     -- set backcolor (a "to set" handler, below) depending on
  4625.     -- the number of colors displayed.
  4626.     get numColors()
  4627.     if it > 16 or it = 0
  4628.         set backcolor of this book to darkerBlue()
  4629.     else
  4630.         set backcolor of this book to lighterBlue()
  4631.     show viewer "navigationBar"
  4632.     in viewer "navigationBar"
  4633.         -- initialize combobox and field in navigation window
  4634.         set text of combobox "categories" to "<All topics>"
  4635.         send populate "All" to field "Topics"
  4636.     if sysLevel is not "reader"
  4637.         send reader
  4638.     else
  4639.         send hideControls
  4640. to handle leaveApplication
  4641.     remove menuitem "helpTemplate" in menu "help" at author
  4642. -- show buttons for modifying book
  4643. to handle author
  4644.     forward
  4645.     send showControls
  4646. to handle showControls
  4647.     show group "CategoryButtons" of page "Navigation"
  4648.     set item 4 of bounds of field "topics" of page "Navigation" to \
  4649.      item 2 of bounds of group "CategoryButtons" of page "Navigation" - 60
  4650.     send sizetopage
  4651. -- hide buttons for modifying book
  4652. to handle reader
  4653.     forward
  4654.     send hideControls
  4655. to handle hideControls
  4656.     hide group "CategoryButtons" of page "Navigation"
  4657.     set item 4 of bounds of field "topics" of page "Navigation" to \
  4658.      item 4 of bounds of group "CategoryButtons" of page "Navigation"
  4659.     send sizetopage
  4660. to handle destroy
  4661.     -- if a page is deleted, updates the category array (struct[][]) userProperty 
  4662.     -- of this book.
  4663.     -- Each row of the category array has the category name and a list
  4664.     -- of the id numbers of pages belonging to that category. This handler
  4665.     -- walks through the array, finding every instance of that id number.
  4666.     -- when found, it removes it.
  4667.     if object of target is "page" and name of parent of target is in "description and script,description and example,description only"
  4668.         local x[][]
  4669.         set x to categoryStruct of this book
  4670.         set pageID to idnumber of target
  4671.         step i from 1 to item 1 of dimensions(x)
  4672.             get itemOffset(pageID,x[i][2])
  4673.             if it > 0
  4674.                 clear item it of x[i][2]
  4675.             end
  4676.         end
  4677.         set categoryStruct of this book to x
  4678.     forward
  4679. to handle enterPage
  4680.     forward
  4681.     -- if this is a content background
  4682.     if name of parent of this page is in "description and script,description and example,description only"
  4683.         -- to ensure the recordfield is set to the label property
  4684.         -- the label property holds the name of each topic
  4685.         set fref to recordfield "subTopicName" of this page
  4686.         if text of fref is not label of this page
  4687.             set text of fref to label of this page
  4688.         end
  4689.         -- set the scroll of the recordfield, if necessary
  4690.         set fref to recordfield "explanation"
  4691.         if scroll of fref is not 0
  4692.             set scroll of fref to 0
  4693.         end
  4694.         -- add/remove scrollbars, if necessary
  4695.         set txtOver to textoverflow of fref
  4696.         conditions
  4697.             when txtOver > 0 and borderstyle of fref is "none"
  4698.                 set borderstyle of fref to "scrolling"
  4699.             when txtOver = 0 and borderstyle of fref is "scrolling"
  4700.                 set borderstyle of fref to "none"
  4701.         end
  4702. to handle leavePage
  4703.     forward
  4704.     if name of parent of this page is in "description and script,description and example,description only"
  4705.         set topic to text of recordfield "subTopicName"
  4706.         if label of this page is not topic
  4707.             set label of this page to topic
  4708.         end
  4709. --========================= Utility handlers ===========================
  4710. -- returns the text before a tab
  4711. to get extractName t
  4712.     set tabOffset to offset(tab,t)
  4713.     return chars 1 to tabOffset-1 of t
  4714. -- returns the text following a tab
  4715. to get extractID t
  4716.     set lastTabLoc to charcount(t)
  4717.         decrement lastTabLoc
  4718.     until lastTabLoc <=0 or char lastTabLoc of t is tab
  4719.     if lastTabLoc <=0
  4720.         return null
  4721.     else
  4722.         return chars lastTabLoc+1 to charcount(t) of t
  4723. -- returns the offset of item itm in list lst
  4724. to get itemOffset itm,lst
  4725.     step i from 1 to itemcount(lst)
  4726.         pop lst
  4727.         if itm = it
  4728.             return i
  4729.         end
  4730.     return 0
  4731. -- removes all instances of a char from a string
  4732. to get stripChar chr,strng
  4733.     while strng contains chr
  4734.         clear char offset(chr,strng) of strng
  4735.     return strng
  4736. -- returns the number of colors displayed
  4737. to get numColors
  4738.     hdc = getDC(windowhandle of mainWindow)
  4739.     retval = getDeviceCaps(hdc,24)
  4740.     get releaseDC(windowhandle of mainwindow,hdc)
  4741.     return retval
  4742. to get darkerBlue
  4743.     return 212,79.1875,71.6875
  4744. to get lighterBlue
  4745.     return 180,75.125,100
  4746. to set backColor to value
  4747.     set bckgrnds to "intro,description and script,description and example,description only"
  4748.     step i from 1 to itemcount(bckgrnds)
  4749.         pop bckgrnds
  4750.         set curBack to background it
  4751.         if fillcolor of curBack is not value
  4752.             set fillcolor of curBack to value
  4753.         end
  4754. --================ Handlers for dealing with array structure ============
  4755. -- display the array in a request box.
  4756. -- (used during authoring for debugging purposes)
  4757. to handle showCategoryStruct
  4758.     local x[][]
  4759.     set x to categoryStruct of this book
  4760.     local retval
  4761.     step i from 1 to item 1 of dimensions(x)
  4762.         put x[i][1] after retval
  4763.         put tab & x[i][2] & crlf after retval
  4764.     request retval
  4765. --------------- these handers sort the array --------------------
  4766. to handle twoDquicksort fArray[][],n,dtype
  4767.     system stbk_noSwap
  4768.     set stbk_noSwap to 0
  4769.     send twoDquicksrt fArray, 1, item 1 of dimensions(fArray),n,dtype
  4770. to handle twoDquicksrt fArray[][], l, r,n,dtype
  4771.     system  stbk_noSwap
  4772.     if r > l 
  4773.         send swap  fArray, l, ((l+r) div 2)
  4774.         set lst to l
  4775.         step i from (l+1) to r
  4776.             conditions
  4777.                 when dtype is "text"
  4778.                     set test to fArray[i][n] < fArray[l][n] as text
  4779.                 when dtype is "date"
  4780.                     set test to fArray[i][n] < fArray[l][n] as date
  4781.                 else
  4782.                     set test to fArray[i][n] < fArray[l][n] as number
  4783.             end
  4784.             if test
  4785.                 increment lst
  4786.                 send swap fArray, lst, i
  4787.             else
  4788.                 increment stbk_noswap
  4789.             end if
  4790.         end step
  4791.         send swap fArray,l,lst 
  4792.            
  4793.            send twoDquicksrt fArray, l, lst-1,n,dtype
  4794.         send twoDquicksrt fArray, lst+1,r,n,dtype
  4795.        end
  4796. to handle swap fArray[][], a, b
  4797.     local temp
  4798.     step i from 1 to item 2 of dimensions (fArray)
  4799.         set temp to farray[a][i]
  4800.         set farray[a][i] to farray[b][i]
  4801.         set farray[b][i] to temp
  4802. to handle helpTemplate
  4803.     mydir = name of self
  4804.         clear last char of mydir
  4805.     until last char of mydir is "\" or mydir is null
  4806.     sen = sysErrorNumber
  4807.     se = sysError
  4808.     sysErrorNumber = 0
  4809.     ss = sysSuspend
  4810.     syssuspend = false
  4811.     bref = book (mydir&"tmplhelp.tbk")
  4812.     syssuspend = ss
  4813.     if sysErrorNumber is not 0
  4814.         request "Cannot find book TMPLHELP.TBK"
  4815.     else
  4816.         vref = viewer "help" of bref
  4817.         set defaultpage of vref to page "cbt4" of bref
  4818.         open vref
  4819.         show vref
  4820.     sysErrorNumber = sen
  4821.     sysError = se
  4822. CONTACT.TBK
  4823. T--***************************************************************************
  4824. --                      Asymetrix Contact: dBase sample app.
  4825. --                             
  4826. --                        Asymetrix Corporation 1994
  4827. -- Authored by Charles Hiestand & Jeff Ayars
  4828. -- Copyright 
  4829.  1994  Asymetrix Corporation
  4830. -- Asymetrix gives you permission to copy, revise and reuse the individual 
  4831. -- objects and scripts in this application in your own applications.  
  4832. -- You may not, however, copy the entire book (or a substantial part of it) 
  4833. -- for redistribution as your own product.
  4834. -- Asymetrix retains the copyright on the original elements of this 
  4835. -- application. Include the notice "Portions of this application are the 
  4836. -- copyright of Asymetrix Corporation" in your product if they contain 
  4837. -- objects or scripts copied from this application.
  4838. -- A note on language independence:  For ease of translating this 
  4839. -- application, all text strings visible to readers that come from scripts 
  4840. -- are put into functions located at the bottom of this book script.  
  4841. --*******************************************************************************
  4842. --************************ Handlers for built in messages ***************************
  4843. -- initialize the path, the text fields, link TB30DB3.DLL, open the dBase files
  4844. to handle enterApplication
  4845.     system s_bookPath
  4846.     system LOGICAL s_firstFlag
  4847.     sysLevel = reader
  4848.     sysCursor = none
  4849.     sysLockScreen = TRUE
  4850.     s_firstFlag = TRUE
  4851.     s_bookPath = name of this book
  4852.     while last character of s_bookPath <> "\"
  4853.         clear last character of s_bookPath
  4854.     end while
  4855.     send linkDB3
  4856.     set sysCursor to default
  4857.     get OpenDBFile(s_bookPath & "contact.dbf")
  4858.     if it < 0
  4859.         request stringOpenError("contact.dbf")
  4860.     else
  4861.         index of this book = "name.ndx"
  4862.         checked of button "name" = TRUE
  4863.         selectedTextlines of field "records" = 1
  4864.         focus = field "records"
  4865.         send updateRecords to field "records"
  4866.     end if
  4867.     -- Make sure book is initialized to browse mode
  4868.     if caption of button "edit" of page 1 = stringResource("Browse")
  4869.         send buttonClick to button "edit" of page 1
  4870.     end if
  4871.     sysLockScreen = FALSE
  4872.     show mainWindow
  4873.     show viewer "splash"
  4874.     forward
  4875.     pause 2 seconds
  4876.     close viewer "splash"
  4877. end enterApplication
  4878. to handle leaveApplication
  4879.     get closeAllDBFiles()
  4880.     unlinkDLL sysToolBookDirectory & "TB30DB3"
  4881.     forward
  4882. end leaveApplication
  4883. to handle idle
  4884. -- we make doubly sure that the window sizes correctly
  4885.     system s_firstFlag
  4886.     forward
  4887.     if s_firstFlag is TRUE
  4888.         clear s_firstFlag
  4889.         send sizeToPage
  4890.     end if
  4891. end idle
  4892. -- Handles all the help messages in the status bar.
  4893. -- The property "helpText" is either a keyword or null for every object in
  4894. -- the book. StringHelp uses the keyword to return the displayed text.
  4895. to handle mouseEnter
  4896.     caption of statusBar = stringHelp(helpText of target)
  4897. end mouseEnter
  4898. to handle mouseLeave
  4899.     caption of statusBar = " "
  4900. end mouseLeave    
  4901. to handle enterMenu mName,mAlias
  4902.     if mName = "File"
  4903.         enable menuItem "printReport"
  4904.     end if
  4905.     forward
  4906. end enterMenu
  4907. -- "About", just the splash screen.
  4908. to handle about
  4909.     show viewer "splash" as modal
  4910. end about
  4911. -- "Quick Help"
  4912. to handle quickHelp
  4913.     show viewer "Quick Help" as modal
  4914. end quickHelp
  4915. -- Simple save handler
  4916. -- More for creating and debugging
  4917. to handle save
  4918.     forward
  4919.     send updateDB    
  4920. end save
  4921. -- These prevent resizing problems in 640 X 480 mode.
  4922. -- In higher modes, it may look better to not have these handlers.
  4923. to handle reader
  4924.     forward
  4925.     send sizeToPage
  4926. end reader
  4927. to handle author
  4928.     forward
  4929.     send sizeToPage
  4930. end author
  4931. --*******************************************************************************
  4932. --*********************** Handlers for custom messages **************************
  4933. -- Links all the functions, but not all functions are used
  4934. to handle linkDB3
  4935.     clear sysError
  4936.     sysSuspend = false -- we'll handle our own errors if linking fails
  4937.     clear sysError
  4938.     linkdll sysToolBookDirectory & "TB30DB3.DLL"
  4939.         INT checkDBIndex(STRING)
  4940.         INT closeAllDBFiles()
  4941.         INT closeDBFile(STRING)
  4942.         INT closeDBIndexFile(STRING)
  4943.         WORD createDBFieldTag(WORD)
  4944.         INT createDBFile(STRING,WORD,WORD)
  4945.         INT createDBIndexFile(STRING,STRING,WORD,WORD)
  4946.         INT deleteDBFile(STRING)
  4947.         INT deselectDBIndexFile()
  4948.         INT findDBKey(STRING)
  4949.         INT firstDBKey()
  4950.         INT firstDBRecord()
  4951.         INT freeDBFieldTag(WORD)
  4952.         STRING getDBDateFormat()
  4953.         STRING getDBErrorString(INT)
  4954.         INT getDBFieldCount()
  4955.         STRING getDBFieldName(WORD)
  4956.         INT getDBFieldPrecision(STRING)
  4957.         INT getDBFieldType(STRING)
  4958.         STRING getDBFieldValue(STRING)
  4959.         INT getDBFieldWidth(STRING)
  4960.         STRING getDBFileName()
  4961.         STRING getDBIndexExpression()
  4962.         STRING getDBIndexFileName()
  4963.         INT getDBKeyType()
  4964.         STRING getDBKeyValue()
  4965.         INT getDBNavigateToDeleted()
  4966.         LONG getDBRecordCount()
  4967.         INT getDBRecordDeleted()
  4968.         LONG getDBRecordNumber()
  4969.         INT gotoDBRecord(DWORD)
  4970.         INT lastDBKey()
  4971.         INT lastDBRecord()
  4972.         INT nextDBKey()
  4973.         INT nextDBRecord()
  4974.         INT openDBFile(STRING)
  4975.         INT openDBIndexFile(STRING)
  4976.         INT packDBFile()
  4977.         INT previousDBKey()
  4978.         INT previousDBRecord()
  4979.         INT reindexDBFile(STRING)
  4980.         INT removeDBRecords(DWORD,DWORD)
  4981.         INT selectDBFile(STRING)
  4982.         INT selectDBIndexFile(STRING)
  4983.         INT setDBDateFormat(STRING)
  4984.         INT setDBFieldTag(WORD,WORD,STRING,STRING,WORD,WORD)
  4985.         INT setDBFieldValue(STRING, STRING)
  4986.         INT setDBNavigateToDeleted(INT)
  4987.         INT setDBRecordDeleted(WORD)
  4988.         INT writeDBRecord(DWORD)
  4989.     end linkdll
  4990.     if sysError <> null
  4991.         request stringError("linkError")
  4992.     end if
  4993. end linkDB3
  4994. -- Gets better scrolling behavior for the field "record".
  4995. -- Many of the buttons on the page have notify handlers for this message
  4996. to handle updateDisplay
  4997.     system ARRAY LONG s_recordNumbertoTextline[]
  4998.     oldFocus = focus
  4999.     currentScroll = scroll of field "records"
  5000.     newScroll = s_recordNumbertoTextline[currentRecord of this book]
  5001.     selectedTextlines of field "records" = newScroll
  5002.     -- size of the bottom scroll of the field is hardwired to "6"
  5003.     fieldSize = textLineCount(text of field "records") - 6
  5004.     if newScroll > currentScroll + 6
  5005.         scroll of field "records" = min(fieldSize,newScroll - 1)
  5006.     else
  5007.         if newScroll < currentScroll + 1
  5008.             scroll of field "records" = max(newScroll - 6,0)
  5009.         end
  5010.     end if
  5011.     focus = oldFocus
  5012. end updateDisplay
  5013. --*********************** Wrappers for TB30DB3.DLL calls ************************
  5014. -- All calls to the DLL are made from here. The rest of the book always
  5015. -- calls these handlers and functions to get to the DLL.
  5016. -- Simple wrapper for getDBFieldValue
  5017. to get fieldValue fieldName
  5018.     clear sysError
  5019.     get getDBFieldValue(fieldName)
  5020.     if sysError is not null
  5021.         request getDBErrorString(syserror)
  5022.         break to system -- prevent notify messages
  5023.     else
  5024.         return it
  5025.     end if
  5026.     return null
  5027. end fieldValue
  5028. -- Simple wrapper for findDBKey. Provides some feedback to the user for two
  5029. -- special cases. FindDBKey returns 3 if it can't find the text, and returns 4
  5030. -- if the search text goes past the last key.
  5031. -- Important: dBaseIII is case sensitive. "a" > "A" !!!
  5032. to handle findKey searchString
  5033.     get findDBKey(searchString)
  5034.     conditions
  5035.     when it = 3
  5036.         request stringResource("findDBKey3")    
  5037.     when it = 4
  5038.         request stringResource("findDBKey4")
  5039.         get lastDBKey()
  5040.     when it < 1
  5041.         request getDBErrorString(it)
  5042.         break to system -- prevent notify messages
  5043.     end conditions
  5044. end findKey
  5045. -- Wrapper for indexing, handles errors until it gives up.
  5046. to set index to value
  5047.     system STRING s_bookPath
  5048.     get getDBIndexFileName()
  5049.     if it is null or value is not in it
  5050.         get openDBIndexFile(s_bookPath & value)
  5051.     get checkDBIndex(s_bookPath & value)
  5052.     if it = 1 -- got it OK
  5053.         get selectDBIndexFile(s_bookPath & value)
  5054.     else
  5055.         get reindexDBFile(s_bookPath & value)
  5056.         if it = -53 -- no index with that name
  5057.             request stringIndexError(value)
  5058.             break to system
  5059.         else
  5060.             if it < 1
  5061.                 request getDBErrorString(it)
  5062.                 break to system -- prevent notify messages
  5063.             end if
  5064.         end if
  5065.     end if
  5066. end index
  5067. --- Simple wrapper for dBase navigation
  5068. to set currentRecord to value
  5069.     conditions 
  5070.     when value = "first"
  5071.         get firstDBKey()
  5072.     when value = "last"
  5073.         get lastDBKey()
  5074.     when value = "next"
  5075.         get nextDBKey()
  5076.     when value = "previous"
  5077.         get previousDBKey()
  5078.     when isType(DWORD, value) and value > 0
  5079.         get goToDBRecord(value)
  5080.     else
  5081.         break
  5082.     end conditions
  5083.     if it < 0
  5084.         if it = -10 -- no such record
  5085.         -- set a flag for updateRecords in script of field "Records" of page 1
  5086.             sysErrorNumber = 65535 
  5087.         else
  5088.             request getDBErrorString(it)
  5089.             break to system -- prevent notify messages
  5090.         end if
  5091.     end if
  5092. end currentRecord
  5093. -- Simple wrapper for setDBFieldValue
  5094. to set fieldValue fieldName to value
  5095.     get setDBFieldValue(fieldName, value)
  5096.     if it < 0
  5097.         request getDBErrorString(it)
  5098.         break to system -- prevent notify messages
  5099.     end if
  5100. end fieldValue
  5101. -- Creates a new (and empty) record.
  5102. -- We won't update the textfield until after we have created 
  5103. -- the first, last, and company names for the record.
  5104. to handle newDBRecord
  5105.     get writeDBRecord(totalRecords of this book + 1)
  5106.     if it < 0
  5107.         request getDBErrorString(it)
  5108.         break to system -- prevent notify messages
  5109.     end if
  5110. end newDBRecord
  5111. -- Simple wrapper for writeDBRecord. This is where the dBase record 
  5112. -- is actually written out.
  5113. to handle updateDB
  5114.     get writeDBRecord(currentRecord of this book)
  5115.     if it < 0
  5116.         request getDBErrorString(it)
  5117.         break to system -- prevent notify messages
  5118.     else
  5119.         send updateRecords to field "records"
  5120.     end if
  5121. end updateDB
  5122. -- Simple wrapper for setDBRecordDeleted. 
  5123. -- Note also that if we pack the dBase here, 
  5124. -- there's no recovery for a deleted file.
  5125. to handle deleteRecord packFlag
  5126.     get setDBRecordDeleted(1)
  5127.     if it < 0
  5128.         request getDBErrorString(it)
  5129.         break to system -- prevent notify messages
  5130.     end if
  5131.     if autoPack of this book is TRUE or packFlag is TRUE
  5132.         send packDataBase
  5133.     end if
  5134. end deleteRecord
  5135. -- Toggle the autoPack feature
  5136. to handle autoPack -- from menu item
  5137.     get not (menuItemChecked(autoPack)) -- the toggle
  5138.     set autoPack of this book to it
  5139.     if it is TRUE
  5140.         check menuItem autoPack
  5141.     else
  5142.         uncheck menuItem autoPack
  5143.     end if
  5144. end autoPack
  5145. -- Simple wrapper for packDBFile
  5146. to handle packDatabase
  5147.     sysCursor = 4
  5148.     -- also moves to last record in database
  5149.     -- so, to prevent that:
  5150.     if checked of button "name" of page 1
  5151.         set searchText to fieldValue(lastName)
  5152.     else
  5153.         set searchText to fieldValue(Company)
  5154.     end if
  5155.     get packDBFile()
  5156.     if it < 1
  5157.         request getDBErrorString(it)
  5158.         break to system -- prevent notify messages
  5159.     else
  5160.         send resetDBase
  5161.         send findKey searchText
  5162.         send updateDisplay
  5163.         send updateRecords to field "records"
  5164.         get totalRecords of this book
  5165.         if it > 50000
  5166.             -- Print Records can't deal with anything larger than this
  5167.             if it > 65531
  5168.                 request stringError("TooBig") 
  5169.             else
  5170.                 request stringError("AlmostTooBig")
  5171.             end if
  5172.         end if
  5173.     end if
  5174.     sysCursor = default
  5175. end packDatabase
  5176. -- workaround for dBase dll tracking problem
  5177. to handle resetDBase
  5178.     currentRecord of this book = "next"
  5179.     currentRecord of this book = "previous"
  5180. end resetDBase
  5181. --******** For functions, errors must be handled by the caller *************
  5182. -- Simple wrapper for getDBKeyValue
  5183. to get keyValue
  5184.     return getDBKeyValue()
  5185. end keyValue
  5186. -- Simple wrapper for getDBRecordNumber
  5187. to get currentRecord
  5188.     return getDBRecordNumber()
  5189. end currentRecord
  5190. -- Simple wrapper for getDBRecordCount
  5191. to get totalRecords
  5192.     return getDBRecordCount()
  5193. end totalRecords
  5194. --****************** printing ************
  5195. -- utility for printing a single record
  5196. to handle printCurrentRecord
  5197.     sysCursor = 4
  5198.     sysLockScreen = TRUE
  5199.     get objects of group "reportGroup" of page "Print Current Record"
  5200.     step i from 1 to itemCount(it)
  5201.         set text of item i of it to fieldValue(uppercase(name of item i of it))
  5202.     set tPage to this page
  5203.     linkDLL "tb30win.dll"
  5204.         STRING getWinIniVar(STRING,STRING)
  5205.     end linkDLL
  5206.     get getWinIniVar("windows","device")
  5207.     unlinkDLL "tb30Win.DLL"
  5208.     if it is NULL
  5209.         request stringResource("BadPrinter")
  5210.         sysCursor = 1
  5211.         break printCurrentRecord
  5212.     end if
  5213.     clear sysError
  5214.     sS = sysSuspend
  5215.     sysSuspend = FALSE
  5216.     start spooler
  5217.         if sysError <> NULL
  5218.             request stringResource("BadPrinter")
  5219.             sysCursor = 1
  5220.             sysLockScreen = FALSE
  5221.             sysSuspend = sS
  5222.             break printCurrentRecord
  5223.         end if
  5224.         set sysSuspend to sS
  5225.         clear printerConditions
  5226.         printerStyle = "Pages"
  5227.         go to page "Print Current Record"
  5228.         print 1 pages
  5229.     end spooler
  5230.     go to tPage
  5231.     sysLockScreen = FALSE
  5232.     sysCursor = 1
  5233. end printCurrentRecord
  5234. to handle printReport
  5235. --     for hardwired report, see code below.
  5236.     -- first check if there is a printer hooked up
  5237.     clear sysError
  5238.     sS = sysSuspend
  5239.     sysSuspend = FALSE
  5240.     linkDLL "tb30win.dll"
  5241.         STRING getWinIniVar(STRING,STRING)
  5242.     end linkDLL
  5243.     get getWinIniVar("windows","device")
  5244.     unlinkDLL "tb30Win.DLL"
  5245.     if it is NULL
  5246.         request stringResource("BadPrinter")
  5247.         sysCursor = 1
  5248.         break printReport
  5249.     end if
  5250.     -- pack the database, so that records displayed = total records of the dBase.
  5251.     request stringResource("PackDB") with stringResource("Yes") or stringResource("No")
  5252.     if it <> stringResource("Yes")
  5253.         break
  5254.     else
  5255.         send packDatabase
  5256.     end if
  5257.     -- The built in PrintReport is going to be used. Once 
  5258.     -- that's started, there is no way to control it, meaning
  5259.     -- we have to be ready to go, and by the time we get to
  5260.     -- this point, there is really no way to back out of this
  5261.     -- gracefully. So we just take a deep breath and do it.
  5262.     -- This may take a while
  5263.     sysCursor = 4
  5264.     -- nor do we want enterPage or leavePage messages.
  5265.     sysSuspendMessages = TRUE
  5266.     -- and we really don't want to see this!
  5267.     sysLockScreen = TRUE
  5268.     -- cache the current page
  5269.     tPage = this page
  5270.     -- cache the background we'll be using
  5271.     bgRB = background "report builder"
  5272.     go to first page of bgRB
  5273.     set currentRecord of this book to "First"
  5274.     -- this works because we've packed the database.
  5275.     set newPgCount to totalRecords of this book
  5276.     set rFObjs to objects of group "reportGroup" of bgRB
  5277.     -- change reference from explicit background to implicit page
  5278.     step i from 1 to itemCount(rFObjs)
  5279.         clear words 4 to 7 of item i of rFObjs
  5280.     end step
  5281.     set objCount to itemCount(rFObjs)
  5282.     -- now fill the first page, make another, fill it, etc.
  5283.     step i from 1 to newPgCount
  5284.         step j from 1 to objCount
  5285.             set text of item j of rFObjs to \
  5286.               fieldValue(uppercase(name of item j of rFObjs))
  5287.         end step
  5288.         if i < newPgCount
  5289.             set currentRecord of this book to "next"
  5290.             send newpage
  5291.         end if
  5292.     end step
  5293. --=============== allow user to custom build the report =============
  5294.     forward
  5295. --===================================================
  5296. -->>>>>>>>>>  alternative: a hardwired report   <<<<<<<<<<<
  5297. --    printerStyle = "groups"
  5298. --    step i from objCount to 1
  5299. --        push name of item i of rFObjs onto tempStack
  5300. --    end
  5301. --    printerFields = tempStack
  5302. --    printerGroupsAcross = 2
  5303. --    start spooler
  5304. --        print newPgCount pages
  5305. --    end 
  5306. --<<<<<<<<>>>>>>>>>>>
  5307.     -- now get rid of all those extra pages
  5308.     go to page 2 of bgRB
  5309.     step i from 2 to newPgCount
  5310.         send selectPage
  5311.         send clear    
  5312.     end step
  5313.     step i from 1 to objCount
  5314.         clear text of item i of rFObjs
  5315.     end step
  5316.     go to tPage
  5317.     sysCursor = 1
  5318. end printReport
  5319. --****************** Strings *********************
  5320. -- Special string functions
  5321. to get stringOpenError dbf
  5322.      return "Error opening" && dbf & ". It is needed to run this application." \
  5323.       && "Please put it in the same directory as"&& uniqueName of this book & "."
  5324. end stringOpenError
  5325. to get stringIndexError value 
  5326.     return "error opening index file:" && value & \
  5327.       ".  It is needed to run this application." && \
  5328.       "Please put it in the same directory as" && \
  5329.       uniquename of this book & "."
  5330. end stringIndexError
  5331. -- Strings for all occassions.
  5332. to get stringResource keyword
  5333.     conditions
  5334.     when keyword = ""
  5335.         return ""
  5336.     when keyword is "Edit"
  5337.         return "Ed&it"
  5338.     when keyword is "New"
  5339.         return "Ne&w"
  5340.     when keyword is "Yes"
  5341.         return "Yes"
  5342.     when keyword is "No"
  5343.         return "No"
  5344.     when keyWord is "YesNoWarning"
  5345.         return "Yes, no more warnings"
  5346.     when keyword is "escape"
  5347.         return "Cancel"
  5348.     when keyword is "DeleteWarning"
  5349.         return "This action will delete this record. Do you want to continue?"
  5350.     when keyword is "Browse"
  5351.         return "&Browse"
  5352.     when keyword is "nameSearch"
  5353.         return "Name to search for..." & CRLF & "(Search is case sensitive)"
  5354.     when keyword is "companySearch"
  5355.         return "Company to search for..." & CRLF & "(Search is case sensitive)"
  5356.     when keyword = "findDBKey3"
  5357.         if checked of button "name" = TRUE
  5358.             set keyType to "name"
  5359.         else
  5360.             set keyType to "company"
  5361.         end if
  5362.         return "String not found, next" && \
  5363.           keyType && "record becomes the current record."
  5364.     when keyword = "BadPrinter"
  5365.         return "There is a problem with the printer. Make sure it is connected and turned on."
  5366.     when keyword = "findDBKey4"
  5367.         if checked of button "name" = TRUE
  5368.             set keyType to "name"
  5369.         else
  5370.             set keyType to "company"
  5371.         end if
  5372.         return "String not found, and search string is greater than last" && \
  5373.           keyType && "record. Last record of this type becomes the current record."
  5374.     when keyword is "PackDB"
  5375.         return "This will require that all records marked for deletion are discarded." & CRLF & \
  5376.           "This can take a while if there are a lot of records. Shall we continue?" 
  5377.           
  5378.     when keyword is "contents"
  5379.         return "Contact.tbk" & CRLF & "A Simple dBaseIII Sample Application" & CRLF & \
  5380.  1994 Asymetrix Corp." & CRLF & "All Rights Reserved."
  5381.     else -- debug, not for international
  5382.         return "Error: String resource received unknown keyword" && \
  5383.         keyword && "from target" && target & "."
  5384.     end conditions
  5385. end stringResource
  5386. -- Error strings
  5387. to get stringError keyword, trgt
  5388.     conditions
  5389.     when keyword = ""
  5390.         return ""
  5391.     when keyword = "linkError"
  5392.         return "Could not link to TB30DB3.dll"
  5393.     when keyword is "NoMem"
  5394.         return "There is not enough system memory for this operation." && \
  5395.           "Please shut down other applications and try again."
  5396.     when keyword is "stringToBig"
  5397.         get getDBFieldWidth(name of trgt)
  5398.         return "This field will only accept strings up to" && it && "characters long."
  5399.     when keyword is "BadDBase"
  5400.         return "This database is not compatable with Contact.tbk. Switching to Contact.dbf"
  5401.     when keyword is "TooBig"
  5402.         return "This Contact database has become so large as to be unprintable." && \
  5403.           "This application was designed as a demonstration and was not intented for such heavy use." && \
  5404.           "You should delete records that are no longer valid, or consider using a different database application."
  5405.     when keyword is "almostTooBig"
  5406.         return "This Contact database is becoming quite large. You should consider deleting unused records."
  5407.     else -- debug, not for international
  5408.         return "Error: Error string function received unknown keyword:" && \
  5409.         keyword && "from target" && target & "."
  5410. end stringError
  5411. -- Help strings
  5412. to get stringHelp keyword
  5413.     conditions
  5414.     when keyword = ""
  5415.         return ""
  5416.     when keyword = "Edit"
  5417.         return "Toggle between browse/edit mode"
  5418.     when keyword = "New"
  5419.         return "Insert a new record into the database"
  5420.     when keyword = "Delete"
  5421.         return "Delete the current record from the database"
  5422.     when keyword = "Search"
  5423.         return "Search the database for a key in the current index"
  5424.     when keyword = "reset"
  5425.         return "Reset field values"
  5426.     when keyword = "Update"
  5427.         return "Write field values to file"
  5428.     when keyword = "Next"
  5429.         return "Go to the next record"
  5430.     when keyword = "Previous"
  5431.         return "Go to the previous record"
  5432.     when keyword = "FirstName"
  5433.         return "Enter first name"
  5434.     when keyword = "LastName"
  5435.         return "Enter last name"
  5436.     when keyword = "Company"
  5437.         return "Enter company name"
  5438.     when keyword = "Notes"
  5439.         return "Enter notes about person"
  5440.     when keyword = "BillingCD"
  5441.         return "Enter billing code if applicable"
  5442.     when keyword = "Misc"
  5443.         return "Enter other personal information"
  5444.     when keyword = "fCountryCD"
  5445.         return "Enter fax country code"
  5446.     when keyword = "fAreaCode"
  5447.         return "Enter fax area code"
  5448.     when keyword = "fLocalNum"
  5449.         return "Enter fax number"
  5450.     when keyword = "fExtension"
  5451.         return "Enter fax extension"
  5452.     when keyword = "vCountryCD"
  5453.         return "Enter voice country code"
  5454.     when keyword = "vAreaCode"
  5455.         return "Enter voice area code"
  5456.     when keyword = "vLocalNum"
  5457.         return "Enter voice phone number"
  5458.     when keyword = "vExtension"
  5459.         return "Enter voice extension"
  5460.     when keyword = "name"
  5461.         return "Sort the records by last name first"
  5462.     when keyword = "companyButton"
  5463.         return "Sort the records by company first"
  5464.     when keyword = "viewByCompany"
  5465.         return "View name and company fields"
  5466.     when keyword = "viewByPhone"
  5467.         return "View name and phone fields"
  5468.     when keyword is "Records"
  5469.         if caption of button "Edit" is stringResource("Edit")
  5470.             return "Doubleclick to edit selection"
  5471.         else
  5472.             return "Doubleclick to browse selection"
  5473.         end if
  5474.     else -- debug, not for international
  5475.         return "Error: Help string function received unknown keyword:" && \
  5476.         keyword && "from target" && target & "."
  5477.     end conditions
  5478. end stringHelp
  5479. DBEXCHNG.TBK
  5480. R--***************************************************************************
  5481. --                Asymetrix dBase - Paradox - ToolBook Exchange
  5482. --                          1991 - 1994
  5483. --                          Asymetrix Corporation
  5484. --Copyright 
  5485.  1991-1994 Asymetrix Corporation
  5486. --This version authored by Jeff Ayars and Charles Hiestand
  5487. --Asymetrix gives you permission to copy, revise and reuse the individual 
  5488. --objects and scripts in this application in your own applications.  
  5489. --You may not, however, copy the entire book (or a substantial part of it) 
  5490. --for redistribution as your own product.
  5491. --Asymetrix retains the copyright on the original elements of this 
  5492. --application. Include the notice "Portions of this application are the 
  5493. --copyright of Asymetrix Corporation" in your product if they contain 
  5494. --objects or scripts copied from this application.
  5495. --A note on language independence:  For ease of translating this 
  5496. --application, all text strings visible to readers that come from scripts 
  5497. --are put into functions located at the bottom of this book script.  
  5498. --The names of these functions start with the letters: "str".
  5499. --  handlers in this script:
  5500. --      author                      set prompt for save changes
  5501. --      enterApplication            handle housekeeping
  5502. --      leaveApplication            clean up
  5503. --      leavePage                   clean up per page
  5504. --      ImportdBase                    go to option
  5505. --      ExportdBase                   go to option
  5506. --      dBaseHelp                   go to help page
  5507. --      linkFile                    link tb30DOS.dll functions
  5508. --      linkdBase                   link tb30db3.dll functions
  5509. --        last                        go to page 10 if in reader
  5510. --  User defined functions in this script:
  5511. --      isAlNum                     test for alphaNumeric
  5512. --      isNum                       test for numeric
  5513. --      isAlpha                     test for alphabetic
  5514. --      isPosInt                    test for positive integer
  5515. --         nameOnly                    return prefix of file name only.
  5516. --***************************************************************************
  5517. to handle enterApplication
  5518.     system s_firstFlag
  5519.     s_firstFlag = true
  5520.     set sysChangesdb to FALSE
  5521.     if sysRuntime is TRUE
  5522.         request strRuntime()
  5523.         send exit to system
  5524.         break to system
  5525.     end if
  5526.     send reader
  5527.     show mainWindow
  5528.     show viewer "splash"
  5529.     send linkFile
  5530.     send linkdBase
  5531.     send linkPX
  5532.     get initializePX("DBExchange")
  5533.     if it < 0 -- if SHARE.EXE is not running, an error will occur here
  5534. --        request getPXErrorString(it)
  5535.         request "DBEXCHNG.TBK needs SHARE.EXE to work correctly. Please leave Windows and from the DOS prompt type ""share"" followed by the enter key. You can then re-enter Windows and start DBEXCHNG.TBK"
  5536.         request "DBEXCHNG.TBK will now exit."
  5537.         send exit to system
  5538.         break to system
  5539.     end if
  5540.     send sizeToPage  -- center window on screen
  5541.        pause 2 seconds
  5542.     forward
  5543.     close viewer "splash"
  5544. end enterApplication
  5545. to handle leaveApplication   
  5546.     get exitPX()
  5547.     forward
  5548. end leaveApplication
  5549. to handle idle -- make sure the screen is centered
  5550.         --(sometimes in 640 X 480 there is a problem)
  5551.     system s_firstFlag
  5552.     forward
  5553.     if s_firstFlag = TRUE
  5554.         send sizeToPage
  5555.         clear s_firstFlag
  5556.     end if
  5557. end idle
  5558. --ask to saveChanges if they have switched to author mode.
  5559. to handle author
  5560.     set sysChangesDB to TRUE
  5561.     forward
  5562.     send sizeToPage
  5563. end author
  5564. to handle reader
  5565.     forward
  5566.     send sizeToPage
  5567. end reader
  5568. to handle last
  5569.     if sysLevel is reader
  5570.         go to page "Export"
  5571.     else
  5572.         forward
  5573.     end if
  5574. end last
  5575. --*********************************************************************
  5576. --handlers for custom menu alias messages
  5577. --*********************************************************************
  5578. to handle menuItemSelected menuItem, menuAlias
  5579.     conditions
  5580.     when menuItem is "ImportFromDbaseFile"
  5581.         go to page "import Dbase"
  5582.     when menuItem is "ExportToDbase"
  5583.         go to page "export DBase"
  5584.     when menuItem is "ImportFromParadox"
  5585.         go to page "import Paradox"
  5586.     when menuItem is "ExportToParadox"
  5587.         go to page "export Paradox"
  5588.     else
  5589.         forward
  5590.     end conditions
  5591. end menuItemSelected
  5592. to handle dBaseHelp
  5593.     system STRING svReturnPage
  5594.     syscursor = 4
  5595.     -- Do not want to send leave or enterPage because user will
  5596.     -- lose work
  5597.     sysSuspendMessages = TRUE
  5598.     -- Do not modify return page if they are already in help
  5599.     if name of this background <> "exchangeHelp"
  5600.         svReturnPage = name of this page
  5601.     end if
  5602.     if name of this page contains "export"
  5603.         go to page "exporting ToolBook to dBase"
  5604.     else
  5605.         go to page "importing dBase to Toolbook"
  5606.     end if
  5607.     sysCursor = default  -- needed because syssuspendmessages set to TRUE
  5608. end dBaseHelp
  5609. to handle aboutdBase
  5610.     show viewer "splash"
  5611. --    request strAboutDbase()
  5612. end aboutdBase
  5613. --*****************************************************************************
  5614. --handlers to link DLL functions used by the book
  5615. --*****************************************************************************
  5616. --link functions for file dll
  5617. to handle linkFile
  5618.     sysSuspend = FALSE
  5619.     clear sysError
  5620.     linkDLL sysToolBookDirectory & "tb30dos.dll"
  5621.         INT    fileExists(STRING)
  5622.         STRING getFileList(STRING)
  5623.     end linkDLL
  5624.     if syserror is not null
  5625.         request strNoDll ("TB30DOS.DLL")
  5626.         send exit to system
  5627.         break to system
  5628.     end if
  5629.     set syserror to null
  5630.     linkDLL sysToolBookDirectory & "tb30dlg.dll"
  5631.         STRING OpenFileDlg(STRING,STRING,STRING,STRING,INT)
  5632.         STRING saveAsDlg(STRING,STRING,STRING,STRING,INT)
  5633.     end linkDLL
  5634.     if syserror is not null
  5635.         request strNoDll ("TB30DLG.DLL")
  5636.         send exit to system
  5637.         break to system
  5638.     end if
  5639.     linkDLL "kernel"
  5640.         WORD GlobalAlloc(WORD,DWORD)
  5641.         WORD GlobalFree(WORD)
  5642.         POINTER GlobalLock(WORD)
  5643.         WORD GlobalUnlock(WORD)
  5644.     end linkDLL
  5645.     sysSuspend = TRUE
  5646. end linkFile
  5647. to handle linkdBase
  5648.     sysSuspend = FALSE
  5649.     clear sysError
  5650.     linkdll sysToolBookDirectory & "tb30DB3.DLL"
  5651.         INT checkDBIndex(STRING)
  5652.         INT closeAllDBFiles()
  5653.         INT closeDBFile(STRING)
  5654.         INT closeDBIndexFile(STRING)
  5655.         WORD createDBFieldTag(WORD)
  5656.         INT createDBFile(STRING,WORD,WORD)
  5657.         INT createDBIndexFile(STRING,STRING,WORD,WORD)
  5658.         INT deleteDBFile(STRING)
  5659.         INT deselectDBIndexFile()
  5660.         INT findDBKey(STRING)
  5661.         INT firstDBKey()
  5662.         INT firstDBRecord()
  5663.         INT freeDBFieldTag(WORD)
  5664.         STRING getDBDateFormat()
  5665.         STRING getDBErrorString(INT)
  5666.         INT getDBFieldCount()
  5667.         STRING getDBFieldName(WORD)
  5668.         INT getDBFieldPrecision(STRING)
  5669.         INT getDBFieldType(STRING)
  5670.         STRING getDBFieldValue(STRING)
  5671.         INT getDBFieldWidth(STRING)
  5672.         STRING getDBFileName()
  5673.         STRING getDBIndexExpression()
  5674.         STRING getDBIndexFileName()
  5675.         INT getDBKeyType()
  5676.         STRING getDBKeyValue()
  5677.         INT getDBNavigateToDeleted()
  5678.         LONG getDBRecordCount()
  5679.         INT getDBRecordDeleted()
  5680.         LONG getDBRecordNumber()
  5681.         INT gotoDBRecord(DWORD)
  5682.         INT lastDBKey()
  5683.         INT lastDBRecord()
  5684.         INT nextDBKey()
  5685.         INT nextDBRecord()
  5686.         INT openDBFile(STRING)
  5687.         INT openDBIndexFile(STRING)
  5688.         INT packDBFile()
  5689.         INT previousDBKey()
  5690.         INT previousDBRecord()
  5691.         INT reindexDBFile(STRING)
  5692.         INT removeDBRecords(DWORD,DWORD)
  5693.         INT selectDBFile(STRING)
  5694.         INT selectDBIndexFile(STRING)
  5695.         INT setDBDateFormat(STRING)
  5696.         INT setDBFieldTag(WORD,WORD,STRING,STRING,WORD,WORD)
  5697.         INT setDBFieldValue(STRING, STRING)
  5698.         INT setDBNavigateToDeleted(INT)
  5699.         INT setDBRecordDeleted(WORD)
  5700.         INT writeDBRecord(DWORD)
  5701.     end linkdll
  5702.      if sysError <> null
  5703.         request "Could not link to TB30db3.dll"
  5704.     end    if
  5705.     set sysSuspend to true
  5706.     if sysError <> null
  5707.         request strNoDLL("TB30DB3.DLL")
  5708.     end if
  5709.     sysSuspend = TRUE
  5710. end linkdBase
  5711. to handle linkPX
  5712.     -- all are linked, not all are used
  5713.     linkDLL sysToolBookDirectory & "tb30PDX.DLL"
  5714.         INT addPXKey(STRING,STRING,INT)                --PXKeyAdd()
  5715.         INT addPXPassword(STRING)                    --PXPswAdd()
  5716.         INT addPXTable(STRING,STRING)                --PXTblAdd()
  5717.         INT appendPXRecord(STRING)                    --PXRecAppend()
  5718.         INT clonePXBlob(STRING,STRING)                --PXBlobClone()
  5719.         INT closePXBitmapWindow(WORD)
  5720.         INT closePXBlob(INT,INT)                    --PXBlobClose()
  5721.         INT closePXTable(STRING)                    --PXTblClose()
  5722.         INT copyPXTable(STRING,STRING)                --PXTblCopy()
  5723.         INT createPXTable(STRING,STRING,STRING)        --PXTblCreate()
  5724.         INT decryptPXTable(STRING)                    --PXTblDecrypt()
  5725.         INT deletePXPassword(STRING)                --PXPswDel()
  5726.         INT deletePXRecord(STRING)                    --PXRecDelete()
  5727.         INT deletePXTable(STRING)                    --PXTblDelete()
  5728.         INT doesPXTableExist(STRING)                --PXTblExist()
  5729.         INT dropPXBlob(STRING,STRING)                --PXBlobDrop()
  5730.         INT dropPXKey(STRING,STRING,WORD)            --PXKeyDrop()
  5731.         INT emptyPXField(STRING,STRING)
  5732.         INT emptyPXRecord(STRING)                    --PXRecBufEmpty()
  5733.         INT emptyPXTable(STRING)                    --PXTblEmpty()
  5734.         INT encryptPXTable(STRING,STRING)            --PXTblEncrypt()
  5735.         INT exitPX()                                --PXExit()
  5736.         INT freePXGraphicBlob(WORD)
  5737.         INT freePXGraphicBlobPalette(WORD)
  5738.         INT firstPXRecord(STRING)                    --PXRecFirst()
  5739.         LONG getPXBitmapSize(WORD)
  5740.         LONG getPXBlob(INT,DWORD,LONG)                --PXBlobGet()
  5741.         LONG getPXBlobQuick(STRING,STRING,INT)        --PXBlobQuickGet()
  5742.         LONG getPXBlobSize(INT)                        --PXBlobGetSize()
  5743.         STRING getPXErrorString(INT)                --return error string
  5744.         INT getPXFieldCount(STRING)                    --PXRecNFlds()
  5745.         STRING getPXFieldNames(STRING)
  5746.         STRING getPXFieldType(STRING,STRING)        --PXFldType()
  5747.         STRING getPXFieldValue(STRING,STRING)
  5748.         LONG getPXFileSize(STRING)
  5749.         LONG getPXGraphicBlob(INT)
  5750.         LONG getPXGraphicBlobPalette(INT)
  5751.         INT getPXKeyFieldCount(STRING)                --PXKeyNFlds()
  5752.         INT getPXMaxFiles()
  5753.         INT getPXMaxLocks()
  5754.         INT getPXMaxTables()
  5755.         INT    getPXSwapSizeFromINI()
  5756.         INT    getPXMaxTablesFromINI()
  5757.         INT    getPXMaxFilesFromINI()
  5758.         INT    getPXMaxLocksFromINI()
  5759.         STRING getPXMemoBlob(INT)
  5760.         STRING getPXNetErrorUser()                    --PXNetErrUser()
  5761.         STRING getPXNetUserName()                    --PXNetUserName()
  5762.         LONG getPXRaw(STRING,INT)                    --PXRawGet()
  5763.         INT getPXRawDataSize(STRING)
  5764.         LONG getPXRecordCount(STRING)                --PXTblNRecs()
  5765.         LONG getPXRecordNumber(STRING)                --PXRecNum()
  5766.         STRING getPXSortOrder()
  5767.         INT getPXSwapSize()
  5768.         STRING getPXUserInfo()
  5769.         INT gotoPXNetRecordLock(STRING,INT)            --PXNetRecGotoLock()
  5770.         INT gotoPXRecord(STRING,LONG)                --PXRecGoto()
  5771.         INT initializePX(STRING)                    --PXWinInit()
  5772.         INT insertPXRecord(STRING)                    --PXRecInsert()
  5773.         INT isPXNetRecordLocked(STRING)                --PXNetRecLocked()
  5774.         INT isPXNetTableChanged(STRING)                --PXNetTblChanged()
  5775.         INT isPXTableProtected(STRING)                --PXTblProtected()
  5776.         INT lastPXRecord(STRING)                    --PXRecLast()
  5777.         INT lockPXNetFile(STRING,INT)                --PXNetFileLock()
  5778.         LONG lockPXNetRecord(STRING)                --PXNetRecLock()
  5779.         INT lockPXNetTable(STRING,INT)                --PXNetTblLock()
  5780.         LONG mapPXKey(STRING,STRING,STRING,INT)        --PXKeyMap()
  5781.         INT nextPXRecord(STRING)                    --PXRecNext()
  5782.         LONG openPXBitmapWindow(WORD,WORD,WORD,STRING,INT,STRING)
  5783.         LONG openPXBlobRead(STRING,STRING)            --PXBlobOpenRead()
  5784.         LONG openPXBlobWrite(STRING,STRING,LONG,INT)--PXBlobOpenWrite()
  5785.         INT openPXTable(STRING,STRING,INT,INT)        --PXTblOpen()
  5786.         INT packPXTable(STRING)
  5787.         INT previousPXRecord(STRING)                --PXRecPrev()
  5788.         STRING queryPXKey(STRING)                    --PXKeyQuery()
  5789.         INT refreshPXNetTable(STRING)                --PXNetTblRefresh()
  5790.         INT renamePXTable(STRING,STRING)            --PXTblRename()
  5791.         INT savePX()                                --PXSave()
  5792.         INT searchPXField(STRING,STRING,WORD,INT)    
  5793.         INT searchPXKey(STRING,INT,STRING,INT)        --PXSrchKey()
  5794.         INT setPXBitmapWindowInfo(WORD,WORD,WORD,INT,STRING)
  5795.         INT setPXBlob(INT,DWORD,LONG,WORD)            --PXBlobPut()
  5796.         INT setPXBlobFromFile(INT,DWORD,DWORD,DWORD,STRING)--PXBlobPut()
  5797.         INT setPXFieldValue(STRING,STRING,STRING)    --PXPutAlpha(), PXPutDate(), PXPutDouble(), PXPutLong(), PXPutShort()
  5798.         INT    setPXGraphicBlob(INT,WORD,WORD)            --PXBlobPut()
  5799.         INT setPXGraphicBlobFromFile(INT,STRING)    --PXBlobPut()
  5800.         INT setPXINIMaxFiles(INT)                    --PXSetDefaults()
  5801.         INT setPXINIMaxLocks(INT)                    --PXSetDefaults()
  5802.         INT setPXINIMaxTables(INT)                    --PXSetDefaults()
  5803.         INT setPXMemoBlob(INT,STRING)                --PXBlobPut()
  5804.         INT setPXRaw(STRING,INT,INT)                --PXRawPut()
  5805.         INT setPXSortOrder(STRING)
  5806.         INT setPXINISwapSize(INT)
  5807.         INT setPXTableCreateMode(INT)                --PXTblCreateMode()
  5808.         INT setPXTableMaxSize(INT)                    --PXTblMaxSize()
  5809.         INT setPXUserInfo(STRING)
  5810.         INT unlockPXNetFile(STRING,INT)                --PXNetFileUnlock()
  5811.         INT unlockPXNetRecord(STRING,INT)            --PXNetRecUnlock()
  5812.         INT unlockPXNetTable(STRING,INT)            --PXNetTblUnlock()
  5813.         INT updatePXRecord(STRING)                    --PXRecUpdate()
  5814.         INT upgradePXTable(STRING)                    --PXTblUpgrade()
  5815.         LONG writePXBlobToFile(INT,STRING,INT)        --PXBlobPut()
  5816.         LONG writePXGraphicBlobToFile(INT,STRING,INT)--PXBlobPut()
  5817.       end linkDLL
  5818.       clear sysError
  5819. end linkPX
  5820. --*************************************************************************
  5821. --Functions to support data validation and error checking
  5822. --*************************************************************************
  5823. -- We test the ANSI number of each character. 
  5824. -- See page C-4 (appendix C) of the ToolBook User Manual.
  5825. to get isAlNum string
  5826.     local LONG i
  5827.     step i from 1 to charCount(string)
  5828.         get charToAnsi(char i of string)
  5829.         if (it >= 0  and it <= 47)  or \ 
  5830.            (it >= 91  and it <= 96) or \ 
  5831.            (it >= 58  and it <= 64)    
  5832.             return FALSE
  5833.         end if
  5834.     end step
  5835.     return TRUE
  5836. end isAlNum
  5837. to get isAlpha string
  5838.     local INT i
  5839.     step i from 1 to charCount(string)
  5840.         get charToAnsi(char i of string)
  5841.         if ( it >= 0  and it <= 64)  or (it >= 91  and it <= 96) or (it > 127)
  5842.             return FALSE
  5843.         end if
  5844.     end step
  5845.     return TRUE
  5846. end isAlpha
  5847. -- Instead of replacing ever call to these ToolBook 1.5 functions,
  5848. -- they have been rewritten using the new 3.0 functionality.
  5849. to get isNum str
  5850.     return isType(REAL, str)
  5851. end isNum
  5852. --boolean test for a positive integer
  5853. to get isPosInt str
  5854.     return evaluate(isType(INT,str) and str >= 0)
  5855. end isPosInt
  5856. -- get just the file name from a fully qualified path
  5857. to get nameOnly fFile
  5858.     local WORD vOffset
  5859.     set vOffset to offset ("\",fFile)
  5860.     while vOffset > 0
  5861.         clear chars 1 to vOffset of fFile
  5862.         set vOffset to offset ("\",fFile)
  5863.     end while
  5864.     return fFile
  5865. end nameOnly
  5866. to get strHelp
  5867.     return "Help"
  5868. end strHelp
  5869. to get strAboutDbase
  5870.     -- debug: better about
  5871.     return "dBaseIII (tm) - Paradox (tm) - ToolBook (tm) Exchange" & crlf & \
  5872.       "Copyright (c) 1991 - 1994 -- Asymetrix Corporation" 
  5873. end strAboutDbase
  5874. to get strCloseInstances
  5875.     return "Please close all other instances of ToolBook."
  5876. end strCloseInstances
  5877. to get strRuntime
  5878.     return "This application will only work with the full authoring ToolBook system. It will now close, please restart it using mtb30.EXE"
  5879. end strRuntime
  5880. to get strdbf
  5881.     return "&dBase"
  5882. end strdbf
  5883. to get strDBFileCreationError fName
  5884.     return "There was an error creating dBase file:" && fName
  5885. end strDBFileCreationError
  5886. to get strDBFileOpenError fName
  5887.     return "There was an error opening dBase file:" && fName
  5888. end strDBFileOpenError
  5889. to get strErrNoDBF
  5890.     return "There is no current dBase file. Please select one."
  5891. end strErrNoDBF
  5892. to get strErrRefdbField fField
  5893.     return "Error referencing dBase field:  " & fField
  5894. end strErrRefdbField
  5895. to get strErrDBFWrite
  5896.     return "Error writing dBase record."
  5897. end strErrDBFWrite
  5898. to get strErrSetDBF fField
  5899.     return "There was an error setting value of dBase field: " & fField
  5900. end strErrSetDBF
  5901. to get strErrTag
  5902.     return "Error creating dBase field tag."
  5903. end strErrTag
  5904. to get strErrTbkExe
  5905.     request "There was an error running mtb30.exe."
  5906.     return FALSE
  5907. end strErrTbkExe
  5908. to get strExportDone errCount
  5909.     if errCount = 0
  5910.         return "Export completed."
  5911.     else
  5912.         return "Export completed:  There were" && errCount && "field(s) with" && \
  5913.                 "invalid data."
  5914.     end if
  5915.     return "Export completed."
  5916. end strExportDone
  5917. to get strNoDBFFields
  5918.     return "No dBase fields have been selected yet."
  5919. end strNoDBFFields
  5920. to get strNoDLL fName
  5921.     return "Can't find" && fName & ". Please copy this file to a directory that's in your path, or change your path to include"&&fname&"'s directory, then open this book again."
  5922. end strNoDLL
  5923. to get strSelTBFields
  5924.     return "Please select ToolBook fields for export."
  5925. end strSelTBFields
  5926. to get strSetDBName
  5927.     return "Please enter a dBase file name."
  5928. end strSetDBName
  5929. to get strTagErr index
  5930.     return "Error setting field tag for field " && index & "." 
  5931. end strTagErr
  5932. to get strTBErrorRef fName
  5933.     return "There was an error referencing book:  " & fname
  5934. end strTBErrorRef
  5935. to get strTBrecordError fField
  5936.     return "Error referencing record field:" && fField
  5937. end strTBrecordError
  5938. to get strEnterDBfile
  5939.     return "Please enter a valid dBase file name."
  5940. end strEnterDBfile
  5941. to get strNoOpenDBfile
  5942.     return "File cannot be opened.  Please enter a valid dBase file name."
  5943. end strNoOpenDBfile
  5944. to get strNoNameOrType
  5945.     return "There is no name or type for one of the fields. Please set the values."
  5946. end strNoNameOrType
  5947. to get strSeldBFileName
  5948.     return "Please select a dBase file name."
  5949. end strSeldBFileName
  5950. to get strErrListdBFile
  5951.     return "Error listing fields for this dBase file."
  5952. end strErrListdBFile
  5953. to get strSelTBKFileName
  5954.     return "Please select a ToolBook file name."
  5955. end strSelTBKFileName
  5956. to get strNoNameRecFfl
  5957.     return "No named, ungrouped record fields were found on the last page of this ToolBook file."
  5958. end strNoNameRecFfl
  5959. to get strTwoShareName
  5960.     return "Two or more record fields share the same name in this book.  Please give all recordfields unique names."
  5961. end strTwoShareName
  5962. to get strNoRecIndBase
  5963.     return "There are no records in this dBase file."
  5964. end strNoRecIndBase
  5965. to get strErrorFirstdBRec
  5966.     return "Error getting the first record in this dBase file."
  5967. end strErrorFirstdBRec
  5968. to get strErrorGetdBValue curFld, totrecs
  5969.     return "Error getting value for field" && \
  5970.       curFld && "in record number" && totrecs & "."
  5971. end strErrorGetdBValue
  5972. to get strErrSetdBValue curfld, totrecs
  5973.     return "Error setting value for record field" && \
  5974.       curfld && "in record number" && totrecs & "."
  5975. end strErrSetdBValue
  5976. to get strToManyFlds
  5977.     return "You are importing more fields than can be displayed on the page." && \
  5978.       "You will have to arrange the fields after the book is built."
  5979. end strToManyFlds
  5980. to get strOK
  5981.     return "OK"
  5982. end strOK
  5983. to get strCancel
  5984.     return "Cancel"
  5985. end strCancel
  5986. to get strPlChooseBook
  5987.     return "Please choose the book to export."
  5988. end strPlChooseBook
  5989. to get strChooseBook
  5990.     return "Choose Book"
  5991. end strChooseBook
  5992. to get strPlChooseDbase
  5993.     return "Please choose the dBase file to import."
  5994. end strPlChooseDbase
  5995. to get strChoosedBase
  5996.     return "Choose dBase File"
  5997. end strChoosedBase
  5998. to get strFieldOverrun fType
  5999.     return "You have exceeded the size limits of a " & fType && ".dbf field."
  6000. end strFieldOverrun
  6001. to get strPrecisionError
  6002.     return "Decimal precision must be either zero or at least two less than the field width."
  6003. end strPrecisionError
  6004. to get strAskDateFormat fldName
  6005.     return "Enter the ToolBook date format of the text in record field" && \
  6006.       fldName & "."
  6007. end strAskDateFormat
  6008. to get strdBnameExist dbName
  6009.     return "Filename" && dbName && "already exists. Replace it?"
  6010. end strdBnameExist
  6011. to get strSavedBaseFile
  6012.     return "Save dBase file as:"
  6013. end strSavedBaseFile
  6014. to get strSavePXFile
  6015.     return "Save Paradox file as:"
  6016. end strSavePXFile
  6017. to get strCharWidth
  6018.     return "Character width must be between 1 and 255."
  6019. end strCharWidth
  6020. to get strNumWidth
  6021.     return "Numeric width must be between 1 and 19."
  6022. end strNumWidth
  6023. to get strWidthNull
  6024.     return "Width cannot be blank."
  6025. end strWidthNull
  6026. to get strDecimalNull
  6027.     return "Decimal cannot be blank."
  6028. end strDecimalNull
  6029. to get strDecimal15
  6030.     return "Decimal cannot be greater than 15."
  6031. end strDecimal15
  6032. to get strNameToLarge
  6033.     return "A dBase field name can only be up to 10 characters."
  6034. end strNameToLarge
  6035. to get strNameNull
  6036.     return "A dBase field name cannot have a blank name." 
  6037. end strNameNull
  6038. to get strChar1Num
  6039.     return "A dBase field name cannot start with a number."
  6040. end strChar1Num
  6041. to get strNotPage
  6042.     return "This is not a functioning page for this book.  It is used to build the front end."
  6043. end strNotPage
  6044. to get strYes
  6045.     return "Yes"
  6046. end strYes
  6047. to get strTooTooManyFields num
  6048.     return "You can only build the new application with" && num && "fields if you" \
  6049.                && "don't include label fields. Do you want to eliminate the label fields?"
  6050. end strTooTooManyFields
  6051. to get strWayTooManyFields
  6052.     return "You have selected more fields than this application can handle." \
  6053.                  && "Please try again with less fields."
  6054. end strWayTooManyFields
  6055. to get strNoLabels
  6056.     return "No label fields"
  6057. end strNoLabels
  6058. to get strNo
  6059.     return "No"
  6060. end strNo
  6061.