home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / CGIshell 1.3.2 / Pocket 6.5 / Examples / Reader.pf < prev    next >
Encoding:
Text File  |  1995-11-11  |  22.3 KB  |  538 lines  |  [TEXT/McSk]

  1. ( Reader application for Pocket Forth 0.6.5 )
  2. : .. ( -- ) key 13 = 0= IF bye ?terminal drop THEN  0 28 +md ! ;
  3. page
  4. ( *******************  W A R N I N G  ******************** )
  5. (   This file creates the ReadMe application. Do NOT run   )
  6. ( this file on a normal copy of Pocket Forth. Instead make )
  7. ( a SPECIAL copy using ResEdit:                            )
  8. (   1} Open a copy of ReadMe with ResEdit                  )
  9. (   2} Delete the DICT 257 resource from ReadMe            )
  10. (   3} Open a copy of Pocket Forth with ResEdit            )
  11. (   4} Copy the DICT 257 resource from Pocket Forth        )
  12. (   5} Paste the DICT 257 resource into ReadMe             )
  13. (   6} Save ReadMe with ResEdit                            )
  14. (   7} Quit ResEdit and Open ReadMe                        )
  15. (   8} Type "open" and open Reader                         )
  16. (   9} Press the return key, wait until ReadMe quits.      )
  17. (  10} Restart ReadMe.                                     )
  18. (  Type return to continue, anything else to quit. )  ..
  19.  
  20. forget task : task ;
  21.  
  22. : !FONT ( n -- ) >r ,$ A887 ; macro  ( _TextFont )
  23. : !FSIZE ( n -- ) >r ,$ A88A ; macro  ( _TextSize )
  24. : !FACE ( face -- ) >r ,$ A888 ; macro ( _TextFace )
  25. : SFONT ( -- ) 0 !font  12 !fsize ;  ( 12 point Chicago )
  26. : NFONT ( -- ) 4 !font  12 !fsize ;  \ 12 point Monaco
  27. : AFONT ( -- ) 1 !font  10 !fsize ;  \ 10 point Geneva
  28. : LFONT ( -- ) nfont  9 !fsize ;     \  9 point Monaco
  29. : CLS ( -- ) 4 +md a>r ,$ A8A3  20 20 !pen ;  ( CLear Screen )
  30.  
  31. ( old style colors )
  32. : BLACK    33 0 2>r ,$ A862 ;  ( black _ForeColor )
  33. : RED     205 0 2>r ,$ A862 ;  ( red _ForeColor )
  34. : BLUE     409 0 2>r ,$ A862 ;  ( blue _ForeColor )
  35.  
  36. ( rect words )
  37. : RECT ( compile: -- ) ( run: -- addr ) variable 6 allot ;
  38. : !RECT ( t l b r rect -- ) >r  swap r 4 + 2!  swap r> 2! ;
  39. : @RECT ( rect -- t l b r ) dup 2@ swap  rot 4 + 2@ swap ;
  40. : ROFFSET ( h v rect -- ) a>r 2>r ,$ A8A8 ;  ( _OffsetRect )
  41. : RINSET ( h v rect -- ) a>r 2>r ,$ A8A9 ;  ( _InsetRect )
  42. : ?EMPTY ( rect -- flag ) 0 >r a>r ,$ A8AE r> ;  ( _EmptyRect )
  43. : RERASE ( rect -- ) a>r ,$ A8A3 ;  ( _EraseRect )
  44.  
  45. : ?PHIT ( h v poly -- flag ) ( true if h,v is in polyBBox )
  46.     0 >r  2@ dl@  2 0 d+  2swap 2>r  2>r ,$ A8AD r> ;  ( _PtInRect )
  47. : POLYGON ( addr -- ) 0 0 2>r ,$ A8CB 2r> rot 2! ;  ( _OpenPoly )
  48.  
  49. ( print PICT resources from this file )
  50. : GETPICT ( id -- dhandle ) 0 0 2>r  >r  ,$ A9BC  2r> ;  ( _GetPict )
  51. : PDRAW ( rect dhandle -- ) ( draw a picture in rect )
  52.     2>r a>r ,$ A8F6 ;  ( _DrawPicture )
  53. : DPICT ( rect id -- ) getpict  pdraw ;
  54.  
  55. ( create and destroy pictures )
  56. : PICTURE ( rect -- dhandle ) ( open a picture )
  57.     0 0 2>r  a>r  ,$ A8F3 2r> ;  ( _OpenPicture )
  58. : PCLOSE ,$ A8F4 ; macro  ( _ClosePicture )
  59. : PKILL ( addr -- ) 2@ 2>r ,$ A8F5 ; ( _KillPicture at addr )
  60.  
  61. \ color availability testing
  62. : ?COLOR ( -- f ) \ true if color is available and system>6.0.4
  63.     ,s qd   ?gestalt dup IF  2drop 256 < 0= THEN ; 
  64.  
  65. ( icons )
  66. : CIGET ( id -- d.handle ) ( call once per icon )
  67.     0 0 2>r >r  \ push room and id
  68.     ?color IF ,$ AA1E      ( _GetCIcon )
  69.     ELSE ,$ A9BB  THEN 2r> ;  ( _GetIcon )
  70. : CIPLOT ( rect d.handle -- ) \ draw icon in rect
  71.     rot a>r 2>r
  72.     ?color IF ,$ AA1F  ( _PlotCIcon )
  73.     ELSE ,$ A94B  THEN ;  ( _PlotIcon )
  74.  
  75.  
  76. ( polygons for the 'NEXT' and 'PREV' "buttons" )
  77. 2variable APOLY  ( aft button poly handle  )
  78. 2variable FPOLY  ( fore button poly handle )
  79. : +APOLY ( -- ) apoly polygon
  80.     5 225 !pen 20 210 -to 50 210 -to
  81.     50 240 -to 20 240 -to  5 225 -to
  82.     ,$ A8CC ;  ( _ClosePgon )
  83. : +FPOLY ( -- ) fpoly polygon
  84.     440 225 !pen 425 210 -to 390 210 -to
  85.     390 240 -to  425 240 -to 440 225 -to
  86.     ,$ A8CC ;  ( _ClosePgon )
  87.  
  88. ( display "buttons" )
  89. : .POLY ( addr -- ) blue  2@ 2>r ,$ A8C6  black ;  ( _FramePoly )
  90. : .AARROW ( -- ) 015 230 !pen ." Prev"  apoly .poly ;
  91. : .FARROW ( -- ) 396 230 !pen ." Next"  fpoly .poly ;
  92. : .ARROWS ( -- ) .aarrow .farrow ;
  93.  
  94.  
  95. \ display icons
  96. variable ICONTABLE  0 iconTable !  12 allot   \ room for 2 icons
  97.     ( no.of.entries   id#1  handle#1  id#2  handle#2  )
  98. : >ICON ( index -- addr ) 6 * iconTable 2+ + ; \ icon list entry (0 based)
  99. : +ICON ( id -- ) \ loads icon from disk and stores data in table
  100.     iconTable @ >icon   \   get entry address
  101.     2dup !               \  store id into table
  102.     swap ciget rot 2+ 2!  \ get & store handle
  103.     1 iconTable +! ;
  104. : .ICON ( id rect -- ) \ display icon in rect
  105.     SWAP  iconTable @ 0 DO  \  search the icon table ..
  106.       r >icon @ over = IF    \ .. for the id wanted
  107.         drop  r >icon 2+ 2@  ciplot LEAVE
  108.     THEN  LOOP ;
  109.  
  110.  
  111. \ Flying Bird stuff
  112. rect BRECT  0 0 14 28 brect !rect  ( the bird's rect )
  113. rect OBRECT  0 0 0 0 obrect !rect  ( old brect )
  114. 2variable B1PICT  ( hold b1's pict handle )
  115. 2variable B2PICT  ( hold b2's pict handle )
  116. 2variable B3PICT  ( hold b3's pict handle )
  117.  
  118. ( draw the three bird positions )
  119. : .B1  red 2 0 !pen 6 0 -to 12 6 -to 18 0 -to 22 0 -to  black ;
  120. : .B2  red 0 6 !pen 24 6 -to black ;
  121. : .B3  red 2 12 !pen 6 12 -to 12 6 -to 18 12 -to 22 12 -to black ;
  122.  
  123. : +BIRD \ initialize the birds pictures & store the handles
  124.     brect picture .b1 pclose b1pict 2!
  125.     brect picture .b2 pclose b2pict 2!
  126.     brect picture .b3 pclose b3pict 2!
  127.     0 0 0 0 brect !rect  0 0 0 0 obrect !rect ;
  128. : -BIRD  b1pict pkill b2pict pkill b2pict pkill ;
  129.  
  130. : B1 brect b1pict 2@ pdraw ;
  131. : B2 brect b2pict 2@ pdraw ;
  132. : B3 brect b3pict 2@ pdraw ;
  133. create .BS  ' b1 ,  ' b2 ,  ' b3 ,  ( bird draw array )
  134. variable BTHIS  0 bthis !  ( offset to the current routine )
  135. 4 constant #BIRDS  \ (number_of_birds-1)*2
  136.  
  137. : THISBIRD ( -- n ) bthis @ ;  \   the current bird
  138. : NEXTBIRD ( -- ) 2 bthis +! ;  \  set bthis to the next bird
  139. : FIRSTBIRD ( -- ) 0 bthis ! ;   \ first picture in sequence
  140. : .BIRD ( n -- ) .bs + @  execute ;  \ draw bird n
  141.  
  142. : MOVEBIRD 3 -1 brect roffset ;  \  translate brect down1 for 3right
  143. : SHRINKBIRD 1 1 brect rinset ;   \ shrink brect by 2 pixels
  144.  
  145. : ANIMATE ( -- ) ( draw the flying red bird )
  146.     brect ?empty IF                   \ if bird has shrunk to oblivion...
  147.       48 291 60 309 brect !rect  THEN  \ ...restore its origonal size
  148.     obrect rerase                  \   erase the old rect
  149.     brect @rect obrect !rect        \  set old rect to current rect
  150.     0 -1 obrect rinset               \ expand old rect for full erasure
  151.     thisBird .bird                    \ draw the bird
  152.     thisBird #birds < IF            \    if its bird 1 or 2
  153.       nextBird  moveBird             \   increment bird and move rect
  154.     ELSE                              \  its bird 3
  155.       firstBird moveBird shrinkBird    \ cycle, move & shrink
  156.     THEN ;
  157.  
  158.  
  159. ( rects for pictures )
  160. rect PRECT   15  48 212 405 prect !rect  ( title picture rect )
  161. rect SRECT  192 222 221 370 srect !rect  ( signature rect )
  162. rect IRECT  170 194 203 227 irect !rect  ( icon rect )
  163.  
  164. : SCR ( -- ) @pen swap drop 16 + 50 swap !pen ;  ( special cr )
  165. : LCR ( -- ) @pen swap drop 12 + 50 swap !pen ;  ( little scr )
  166. : BCR ( -- ) @pen swap drop 50 swap !pen ;  ( cr without lf )
  167.  
  168. : .CONT ( -- ) 175 230 !pen ." ( continued ... )" ;
  169.  
  170. ( P1 - P? are page drawing routines.  They have no stack effect.)
  171. : P1  cls  prect 4000 dpict .farrow ;
  172.  
  173. : P2  cls scr
  174.     ."       Its FAST, its FUN and its FREE!" scr scr
  175.     ."    Its Pocket Forth, a programming language for" scr
  176.     ."  writing Macintosh applications and DAs." cr scr
  177.     ."    You can take advantage of many new features" scr
  178.     ."  in this release such as Apple Events*, Floating" scr
  179.     ."  Point, Gestalt** and Drag & Drop* programming." cr scr
  180.     ."    Learn Forth programming with the contents of" scr
  181.     ."  the Starting folder (inside the Extensions folder.)"
  182.     scr scr scr ."            * System 7   ** System 6.0.4+"
  183.     srect 4001 dpict  ( draw signature picture )
  184.     .arrows ;
  185.  
  186. : P3  cls scr
  187.     ."   Code produced by Pocket Forth is compact and fast." cr scr
  188.     ."   Pocket Forth produces 68K machine code, so" scr
  189.     ." you have complete control over your program." cr scr
  190.     ."   Examine and run the example, extension and" scr
  191.     ." contributed files for programming suggestions." cr scr
  192.     ."    If you have system 7 you can load text files by" scr
  193.     ."  dragging a text file icon onto Pocket Forth's icon." cr scr
  194.     ."  All systems can use the menu to “Open” a file."
  195.     143 392 176 425 irect !rect  ( set icon rect )
  196.     128 irect .icon  ( draw the icon )
  197.     .arrows ;
  198.  
  199. : P4  cls scr
  200.     ."   Print and read the Manual and the Glossary." cr scr
  201.     ."   The Manual consists of three TeachText documents" scr
  202.     ." suitable for use as a reference to Pocket Forth." cr scr
  203.     ."   The Glossary, also a TeachText document, is a" scr
  204.     ." list of the words in the Pocket Forth dictionary." scr
  205.     ." Stack effects, pronunciation and usage are shown." cr scr
  206.     ."   User written code and documents are included" scr
  207.     ." as examples and for your use."
  208.     .arrows ;
  209.  
  210. : P5  cls scr
  211.     ." Major changes since release 5:" scr scr
  212.     ."  • Floating point numbers!" cr scr
  213.     ."    Numeric input containing a decimal point is" scr
  214.     ."    interpreted as an extended floating point" scr
  215.     ."    number. Floating Point numbers are kept on" scr
  216.     ."    the stack as ten byte entities."  cr scr
  217.     ."    SANE is used along with three dozen new" scr
  218.     ."    words that manipulate floating point numbers."
  219.     .cont .arrows ;
  220.  
  221. : P6  cls scr
  222.     ." Floating point continued ..." cr scr
  223.     ."    Stack words:      "  2 !face
  224.                            ." fdrop   fdup   fswap   fpick" scr
  225.     ."                               fpack   froll   f>d   d>f" cr scr
  226.     0 !face ."    Memory words: " 2 !face ." f@   f!   fliteral   f," scr
  227.     ."                               fconstant   fvariable" cr scr
  228.     0 !face ."    I/O words:         " 2 !face
  229.                                     ." fnumber   sci   fix   f." cr scr
  230.     0 !face ."    Math words:      " 2 !face
  231.                                     ." fcompare   f+   f-   f*   f/" scr
  232.     ."                               frem   f^   fint   fabs   fsqrt" scr
  233.     ."                               fsin   fcos   ftan   fatn" scr
  234.     ."                               fexp   fln"  0 !face
  235.     .arrows ;
  236.  
  237.  
  238. : P7  cls scr
  239.     ."  • Apple Events:" cr scr
  240.     21 352 54 385 irect !rect  ( set icon rect )
  241.     128 irect .icon  ( draw the icon )
  242.     ."    Apple Events (System 7 required) are the" scr
  243.     ."    standard conduit for inter-application" scr
  244.     ."    communication. Pocket Forth programs may" scr
  245.     ."    define new Apple event handlers. The four" scr
  246.     ."    required events and all user defined events" scr
  247.     ."    are installed automatically when Pocket" scr
  248.     ."    Forth starts." cr scr
  249.     ."    HyperCard, Frontier and AppleScript examples" scr
  250.     ."    are in the 'Extensions:Apple Events' folder."
  251.     .cont .arrows ;
  252.  
  253.  
  254. : P8  cls scr
  255.     ." New words and variables control Apple Events:" cr scr
  256.     2 !face ."    AE:  " 0 !face ." and " 2 !face ." AE:  " 0 !face
  257.     ."    begin and end event definitions" scr
  258.     2 !face ."    ,S  " 0 !face
  259.     ."            compile (or stack) 4 bytes from ASCII" scr afont
  260.     ."                      (also useful in many other contexts)" sfont cr scr
  261.     2 !face  ."    +Md  " 0 !face ." variables:" scr
  262.     ."            136    Apple Event handler routine" scr
  263.     ."            188    Address of installation list" scr
  264.     ."            190    Error handler routine ("
  265.                          2 !face ." drop "  0 !face ." )" scr
  266.     ."            198    Reply record handle holder" scr
  267.     ."            202    Apple Event record handle"
  268.     .arrows ;
  269.  
  270. : P9  cls scr
  271.     ."  • Use " 2 !face ." ?gestalt  " 0 !face
  272.        ." to query the system." cr scr
  273.     ."    Using this new system trap, available since" scr
  274.     ."    late system 6, you can determine much about" scr
  275.     ."    the system software and hardware."  scr scr
  276.     ."  • A color conscious window is created if a" scr
  277.     ."    color machine is in use. This has no visual" scr
  278.     ."    effect but allows your programs to use color." scr scr
  279.     ."  • A new color icon and signature is used."
  280.     336 216 !pen  lfont ." p4TH" sfont
  281.     175 335 207 367 irect !rect  ( set icon rect )
  282.     129 irect .icon  ( draw the icon )
  283.     .arrows ;
  284.  
  285. : P10  cls scr
  286.     ." New for 6.3:" cr scr
  287.     ."  • The word \ makes comments more effecitve." cr scr
  288.     ."  • " 2 !face ." Warm  " 0 !face
  289.         ." restarts Pocket Forth, but leaves" scr
  290.     ."    the dictionary intact." cr scr
  291.     ."  • " 2 !face ." Depth  " 0 !face
  292.         ." lets you know how many items are" scr
  293.     ."    on the stack." scr scr
  294.     ."  • Check out the Balloon Help."
  295.     164 261 197 294 irect !rect  ( set icon rect )
  296.     128 irect .icon  ( draw the icon )
  297.     .arrows ;
  298.  
  299. : P11  cls scr
  300.     ." Bug fixes:" cr scr
  301.     ."  • The manual has been updated." cr scr
  302.     ."  • " 2 !face ." Back  " 0 !face
  303.        ." now compiles correct branches." cr scr
  304.     ."  • A 32 bit address error in the update" scr
  305.     ."    routine has been fixed." cr scr
  306.     ."  • " 2 !face ." Bye  " 0 !face
  307.        ." does not use _ExitToShell." cr scr
  308.     ."  • " 2 !face ." QUIT  " 0 !face
  309.        ." leaves the stack untouched." cr scr
  310.     .cont .arrows ;
  311.  
  312. : P12  cls scr
  313.     ." Bug fixes, continued ...       (New in 6.3)" cr scr
  314.     ."  • Tabs are now converted to spaces before" scr
  315.     ."    interpreting, so they no longer cause errors." cr scr
  316.     ."  • Now works with AppleScript (6.4) in" scr
  317.     ."    addition to Userland's Frontier." cr scr
  318.     ."  • " 2 !face ." +LOOP  " 0 !face
  319.        ." now works correctly (6.5)." cr scr
  320.     ."  • " 2 !face ." TYPE  " 0 !face
  321.        ." handles zero length strings (6.5)."
  322.     96 315 129 348 irect !rect  ( set icon rect )
  323.     128 irect .icon  ( draw the icon )
  324.     .arrows ;
  325.  
  326. : P13  cls scr
  327.     ." Notes:" cr scr
  328.     ."  • A DA version is included. Version 1.6.5" scr
  329.     ."    includes all of the new features except for" scr
  330.     ."    Apple Events support." cr scr
  331.     ."  • " 2 !face ." Grow  " 0 !face
  332.        ." has been removed from the application." scr
  333.     ."    Allocated memory is 32K for both application" scr
  334.     ."    and DA." cr scr
  335.     ."  • Choosing “Save” from the menu confirms your" scr
  336.     ."    choice before overwriting the dictionary." cr scr
  337.     .cont .arrows ;
  338.  
  339. : P14  cls scr
  340.     ." Notes, continued ..." cr scr
  341.     ."  • 68040's instruction cache must be off to" scr
  342.     ."    compile code correctly." cr scr
  343.     ."  • Power Macs compile and run Pocket Forth" scr
  344.     ."    in emulation without problems." cr scr
  345.     ."  • The floating point interpreter will attempt" scr
  346.     ."    to convert any undefined token to a number." scr
  347.     ."    If the token begins with a number, it will" scr
  348.     ."    be converted causing unexpected results."
  349.     .arrows ;
  350.  
  351. : P15  cls scr
  352.     ." Packing list for Pocket Forth, release 6.5:" scr scr
  353.     ."  • The application, Pocket Forth version 0.6.5" scr
  354.     ."  • The desk accessory, PocketDA version 1.6.5" cr scr
  355.     ."  Text files:" scr
  356.     ."  • The Manual parts 1, 2, 3 and a FAQ." scr
  357.     ."  • The Glossary of Pocket Forth words" scr
  358.     ."  • Source code with assembly instructions" scr
  359.     ."     and an assembly script for Frontier." scr
  360.     ."  • Source and Manual Addendum for the DA." cr scr scr
  361.     .cont .arrows ;
  362.  
  363. : P16  cls scr
  364.     ."  • Example folder:           (Packing list cont.)" cr scr
  365.     ."                                   create this application" bcr
  366.     ."      Reader" scr
  367.     ."                                   the guts of a text editor" bcr
  368.     ."      TextEdit" scr
  369.     ."                                   converse with your computer" bcr
  370.     ."      Eliza" scr
  371.     ."                                   the Sieve of Erastothanes" bcr
  372.     ."      Sieve" scr
  373.     ."                                   demonstrate them" bcr
  374.     ."      Window&Menu" scr
  375.     ."                                   floating point trig. functions" bcr
  376.     ."      SANETrig" scr
  377.     ."                                   16/32 bit math functions" bcr
  378.     ."      IntegerTrig" scr
  379.     ."                                   QuickDraw routines with demo" bcr
  380.     ."      Graphics" scr
  381.     ."                                   an RPN scientific calculator" bcr
  382.     ."      Calculator" cr scr scr
  383.     .cont .arrows ;
  384.  
  385. : P17  cls scr
  386.     ."  • Extension folder:          (Packing list cont.)" cr scr
  387.     ."                                    Make Pocket Forth mostly" bcr
  388.     ."      Starting folder" scr
  389.     ."                                    compatable with "
  390.                                           4 !face  ." Starting" bcr
  391.     nfont 2 !face ."     ATTENTION" 0 !face sfont scr
  392.     ."                                    " 4 !face  ." Forth"
  393.                                           0 !face  ."  by Leo Brodie!" bcr
  394.     nfont 2 !face ."      BEGINNERS!" 0 !face sfont cr scr
  395.     ."                                    A folder with new event" bcr
  396.     ."      Apple Events" scr
  397.     ."                                    definitions and interface files for"
  398. scr ."                                    Frontier, HyperCard & AppleScript."
  399.     cr scr
  400.     ."                                    A library of utility and" bcr
  401.     ."      Misc" scr
  402.     ."                                    debugging routines."
  403.     128 94 161 127 irect !rect  ( set icon rect )
  404.     128 irect .icon  ( draw the icon )
  405.     .cont .arrows ;
  406.  
  407. : P18  cls scr
  408.     ."  • Extension folder cont:   (Packing list cont.)" cr scr
  409.     ."                                    Words to manipulate null" bcr
  410.     ."      Strings" scr
  411.     ."                                    terminated strings." cr scr
  412.     ."                                    The Forth Vendors Group" bcr
  413.     ."      fvgFloatingPoint" scr
  414.     ."                                    floating point standard." cr scr
  415.     ."                                    Create, delete and manipulate" bcr
  416.     ."      DataFiles" scr
  417.     ."                                    text files by name or dialog."
  418.     .cont .arrows ;
  419.  
  420. : P19  cls scr
  421.     ."  • Contributions:             (Packing list cont.)" cr scr
  422.     ."                                    How to use sound and pop-up" bcr
  423.     ."      From Consuegra" scr
  424.     ."                                    menus in your programs." cr scr
  425.     ."                                    A fractal drawing program." bcr
  426.     ."      From Gates" scr
  427.     ."                                    Double click on the Mandelbrot" scr
  428.     ."                                    icon to run the program." cr scr
  429.     ."                                    Control the World Wide Web" bcr
  430.     ."      From Kneusel" scr
  431.     ."                                    with this CGI Shell."
  432.     .cont .arrows ;
  433.  
  434. : P20  cls scr
  435.     ."  • Contributions cont.:       (Packing list cont.)" cr scr
  436.     ."                                    Documentation in Japanese and" bcr
  437.     ."      From Nagasawa" scr
  438.     ."                                    some nice animation." cr scr
  439.     ."                                    Case and object oriented" bcr
  440.     ."      From Peters" scr
  441.     ."                                    extensions to Pocket Forth." cr scr
  442.     ."                                    Forth written in Forth!" bcr
  443.     ."      From Webb" cr scr
  444.     ."     Other files from M. Roberts, R. Chuo and others" scr
  445.     ."     are included.  Thanks to all of you!"
  446.     .arrows ;
  447.  
  448. : P21  cls scr
  449.     ."     If you find a bug, need help, or want to talk" scr
  450.     ."    about this, write. I'd like to hear from you and" scr
  451.     ."    I'll attempt to answer your mail." afont ." *" sfont  cr scr
  452.     ."    Contact me at any of the following addresses:" scr
  453.     ."      Email          heilman@pc.maricopa.edu" scr
  454.     ."      U.S. Mail     PO box 8345" scr
  455.     ."                         Phoenix AZ 85066-8345" cr scr
  456.     ."      or on the World Wide Web at the following URL:" scr
  457.     ."        http://chemlab.pc.maricopa.edu/pocket.html" cr lcr lcr
  458.     ."    " afont ." * Be patient though, it takes some time "
  459.     ." for me to make up an answer." lcr sfont
  460.     ."       " afont ." If you haven't heard from me in a week "
  461.     ." or so, write again.  Thanks." sfont
  462.     .aarrow ;
  463.  
  464. \ page list
  465. variable PWHICH  0 pwhich !  ( page-1 to be drawn )
  466. 20 constant PNO  ( number of pages-1 )
  467. create PLIST  ( ordered list of routines or "pages" )
  468.     ' p1 ,  ' p2 ,  ' p3 ,  ' p4 ,
  469.     ' p5 ,  ' p6 ,  ' p7 ,  ' p8 ,
  470.     ' p9 ,  ' p10 , ' p11 ,  ' p12 ,
  471.     ' p13 ,  ' p14 ,  ' p15 ,  ' p16 ,
  472.     ' p17 ,  ' p18 ,  ' p19 ,  ' p20 ,  ' p21 ,
  473.  
  474. ( update, menu, button and idle handlers )
  475. : DOUP  pwhich @ 2* plist + @ execute ;  ( draw the pwhichth page )
  476. : DON ( n -- ) pwhich ! doup ;  ( go to nth page )
  477. : DOAFT  pwhich @ 1 - 0 max don ;  ( decrement pwhich )
  478. : DOFOR  pwhich @ 1+ pno min don ;  ( increment pwhich )
  479. : DOFIRST  0 don ;  ( go to first page )
  480. : DOLAST  pno don ;  ( go to last page )
  481. : DONEW 4 don ;  \ go to "whats new" page
  482. : DOBUG 10 don ;  \ go to "bug fixes" page
  483. : DONOTE 12 don ;  \ go to "notes" page
  484. : DOPACK 14 don ;   \ go to "packing list" page
  485.  
  486. : STOP  -bird bye ; ( stop animating )
  487.  
  488. \ menu list
  489. create GMENU ' dofirst , ' doaft , ' dofor , ' dolast ,
  490.    ' null ,  ' donew ,  ' dobug ,  ' donote ,  ' dopack ,  ' dolast ,
  491. create FMENU ' stop ,
  492. create MBAR fmenu ,  18 +md @ 2+ @ ,  gmenu ,
  493. 2variable GMENUH  0 0 gmenuh 2!  ( holder for goMenuHandle )
  494. ' beep  18 +md @  ( get pointer to menu list )
  495.         2+ @  ( get pointer to Edit menu from menu list )
  496.         8 + !  ( set paste handler to beep )
  497.  
  498. : +MENU ( -- ) ( Turn the new menu on.)
  499.     0 0 2>r 4 >r ,$ A9BF  ( _GetRMenu )
  500.     2r> 2dup 2>r 0 >r ,$ A935  ( _InsertMenu )
  501.     gmenuh 2!  ,$ A937 ;  ( _DrawMenuBar )
  502.  
  503. : DOBUTT  ( -- ) ( button handler )
  504.     @mouse apoly ?phit IF apoly 2@ 2>r ,$ A8C9 doaft ELSE
  505.       @mouse fpoly ?phit IF fpoly 2@ 2>r ,$ A8C9  dofor 
  506.     THEN  THEN ;
  507.  
  508. \ Idle procedure
  509. variable TLAST  0 tlast !  ( timer )
  510. 10 constant DELAY
  511. : TICKS ( -- n ) 364 0 l@ ;
  512. : ?TIME ( -- flags ) ( true if 1/delay seconds has elapsed )
  513.     ticks tlast @ - abs delay > ;
  514. : DOIDLE  ( do the first page animation )
  515.     pwhich @ 0= IF  ( if its the title page )
  516.       ?time IF ticks tlast !  animate
  517.     THEN  THEN ;
  518.  
  519. \ startup procedure
  520. : START  sfont   \ Set to 12 point Chicago
  521.     2 >r ,$ A889  \ SrcXor _TextMode
  522.     +apoly +fpoly       \    This is stuff that must
  523.     +menu  +bird         \   be set up at runtime,
  524.     128 +icon  129 +icon  \  because it uses handles.
  525.     BEGIN ?terminal drop AGAIN ;  ( event loop )
  526.  
  527. \ This is event handlers and data to set up when this is loaded.
  528. ' doup    14 +md !  \ set update handler
  529. ' dobutt  16 +md !  \ set button handler
  530.   mbar    18 +md !  \ set the menu handlers
  531. ' doidle  20 +md !  \ set idle handler
  532. ' stop    22 +md !  \ set quit handler
  533. ' start   26 +md !  \ set startup handler
  534. ' null   136 +md !  \ disable Apple Events
  535. 450 250   8 +md 2!  \ set window size
  536.  
  537. save  bye
  538.