home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / CGIshell Folder / Pocket 6.4 / Examples / Reader < prev    next >
Encoding:
Text File  |  1995-05-17  |  22.3 KB  |  536 lines  |  [TEXT/McSk]

  1. ( Reader application for Pocket Forth 0.6.4 )
  2. : RTEST ( -- ) 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. )  rtest
  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. ( P1 - P? are page drawing routines.  They have no stack effect.)
  169. : P1  cls  prect 4000 dpict .farrow ;
  170.  
  171. : P2  cls scr
  172.     ."       Its FAST, its FUN and its FREE!" scr scr
  173.     ."    Its Pocket Forth, a programming language for" scr
  174.     ."  writing Macintosh applications and DAs." cr scr
  175.     ."    You can take advantage of many new features" scr
  176.     ."  in this release such as Apple Events*, Floating" scr
  177.     ."  Point, Gestalt** and Drag & Drop* programming." cr scr
  178.     ."    Learn Forth programming with the contents of" scr
  179.     ."  the Starting folder (inside the Extensions folder.)"
  180.     scr scr scr ."            * System 7   ** System 6.0.4+"
  181.     srect 4001 dpict  ( draw signature picture )
  182.     .arrows ;
  183.  
  184. : P3  cls scr
  185.     ."   Code produced by Pocket Forth is compact and fast." cr scr
  186.     ."   Pocket Forth produces true machine code, so" scr
  187.     ." you have complete control over your program." cr scr
  188.     ."   Examine and run the example and extension" scr
  189.     ." files for programming suggestions." cr scr
  190.     ."    If you have system 7 you can load text files by" scr
  191.     ."  dragging a text file icon onto Pocket Forth's icon." cr scr
  192.     ."  All systems can use the menu to “Open” a file."
  193.     143 392 176 425 irect !rect  ( set icon rect )
  194.     128 irect .icon  ( draw the icon )
  195.     .arrows ;
  196.  
  197. : P4  cls scr
  198.     ."   Print and read the Manual and the Glossary." cr scr
  199.     ."   The Manual consists of two TeachText documents" scr
  200.     ." suitable for use as a reference to Pocket Forth." cr scr
  201.     ."   The Glossary, also a TeachText document, is a" scr
  202.     ." list of the words in the Pocket Forth dictionary." scr
  203.     ." Stack effects, pronunciation and usage are shown." cr scr
  204.     ."   User written code and documents are now" scr
  205.     ." included as examples and for your use."
  206.     .arrows ;
  207.  
  208. : P5  cls scr
  209.     ." Major changes since release 5:" scr scr
  210.     ."  • Floating point numbers!" cr scr
  211.     ."    Numeric input containing a decimal point is" scr
  212.     ."    interpreted as an extended floating point" scr
  213.     ."    number. Floating Point numbers are kept on" scr
  214.     ."    the stack as ten byte entities."  cr scr
  215.     ."    SANE is used along with three dozen new" scr
  216.     ."    words that manipulate floating point numbers." cr scr scr
  217.     ."                                ( continued ... )"
  218.     .arrows ;
  219.  
  220. : P6  cls scr
  221.     ." Floating point continued ..." cr scr
  222.     ."    Stack words:      "  2 !face
  223.                            ." fdrop   fdup   fswap   fpick" scr
  224.     ."                               fpack   froll   f>d   d>f" cr scr
  225.     0 !face ."    Memory words: " 2 !face ." f@   f!   fliteral   f," scr
  226.     ."                               fconstant   fvariable" cr scr
  227.     0 !face ."    I/O words:         " 2 !face
  228.                                     ." fnumber   sci   fix   f." cr scr
  229.     0 !face ."    Math words:      " 2 !face
  230.                                     ." fcompare   f+   f-   f*   f/" scr
  231.     ."                               frem   f^   fint   fabs   fsqrt" scr
  232.     ."                               fsin   fcos   ftan   fatn" scr
  233.     ."                               fexp   fln"  0 !face
  234.     .arrows ;
  235.  
  236.  
  237. : P7  cls scr
  238.     ."  • Apple Events:" cr scr
  239.     21 352 54 385 irect !rect  ( set icon rect )
  240.     128 irect .icon  ( draw the icon )
  241.     ."    Apple Events (System 7 required) are the" scr
  242.     ."    standard conduit for inter-application" scr
  243.     ."    communication. Pocket Forth programs may" scr
  244.     ."    define new Apple event handlers. The four" scr
  245.     ."    required events and all user defined events" scr
  246.     ."    are installed automatically when Pocket" scr
  247.     ."    Forth starts." cr scr
  248.     ."    HyperCard, Frontier and AppleScript examples" scr
  249.     ."    are in the 'Extensions:Apple Events' folder." cr scr
  250.     ."                                ( continued ... )"
  251.     .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" cr scr
  260.     2 !face  ."    +Md  " 0 !face ." variables:" scr
  261.     ."            136    Apple Event handler routine" scr
  262.     ."            188    Address of installation list" scr
  263.     ."            190    Error handler routine ("
  264.                          2 !face ." drop "  0 !face ." )" scr
  265.     ."            198    Reply record handle holder" scr
  266.     ."            202    Apple Event record handle"
  267.     .arrows ;
  268.  
  269. : P9  cls scr
  270.     ."  • Use " 2 !face ." ?gestalt  " 0 !face
  271.        ." to query the system." cr scr
  272.     ."    Using this new system trap, available since" scr
  273.     ."    late system 6, you can determine much about" scr
  274.     ."    the system software and hardware."  scr scr
  275.     ."  • A color conscious window is created if a" scr
  276.     ."    color machine is in use. This has no visual" scr
  277.     ."    effect but allows your programs to use color." scr scr
  278.     ."  • A new color icon and signature is used."
  279.     336 216 !pen  lfont ." p4TH" sfont
  280.     175 335 207 367 irect !rect  ( set icon rect )
  281.     129 irect .icon  ( draw the icon )
  282.     .arrows ;
  283.  
  284. : P10  cls scr
  285.     ." New for 6.3:" cr scr
  286.     ."  • The word \ makes comments more effecitve." cr scr
  287.     ."  • " 2 !face ." Warm  " 0 !face
  288.         ." restarts Pocket Forth, but leaves" scr
  289.     ."    the dictionary intact." cr scr
  290.     ."  • " 2 !face ." Depth  " 0 !face
  291.         ." lets you know how many items are" scr
  292.     ."    on the stack." scr scr
  293.     ."  • Check out the Balloon Help."
  294.     164 261 197 294 irect !rect  ( set icon rect )
  295.     128 irect .icon  ( draw the icon )
  296.     .arrows ;
  297.  
  298. : P11  cls scr
  299.     ." Bug fixes:" cr scr
  300.     ."  • The manual has been updated.  For best" scr
  301.     ."    results, use TeachText (not SimpleText)" scr
  302.     ."    to view and print the pictures." cr scr
  303.     ."  • " 2 !face ." Back  " 0 !face
  304.        ." now compiles correct branches." cr scr
  305.     ."  • A 32 bit address error in the update" scr
  306.     ."    routine has been fixed." cr scr
  307.     ."  • A new word, " 2 !face ." Bye  " 0 !face
  308.        ." does not use _ExitToShell." scr scr
  309.     ."                                ( continued ... )"
  310.     .arrows ;
  311.  
  312. : P12  cls scr
  313.     ." Bug fixes, continued ...       (New for 6.3)" cr scr
  314.     ."  • " 2 !face ." +LOOP  " 0 !face
  315.        ." now works correctly with" scr
  316.     ."    negative arguments." cr scr
  317.     ."  • " 2 !face ." TYPE  " 0 !face
  318.        ." does not end with a space." cr scr
  319.     ."  • " 2 !face ." QUIT  " 0 !face
  320.        ." leaves the stack untouched." cr scr
  321.     ."  • Tabs are now converted to spaces before" scr
  322.     ."    interpreting, so they no longer cause errors." cr scr
  323.     ."  • Works with AppleScript (0.6.4)."
  324.     185 287 218 320 irect !rect  ( set icon rect )
  325.     128 irect .icon  ( draw the icon )
  326.     .arrows ;
  327.  
  328. : P13  cls scr
  329.     ." Notes:" cr scr
  330.     ."  • A DA version is now included. Version 1.6.3" scr
  331.     ."    includes all of the new features except for" scr
  332.     ."    Apple Events support." cr scr
  333.     ."  • " 2 !face ." Grow  " 0 !face
  334.        ." has been removed from the application." scr
  335.     ."    Allocated memory is 32K for both application" scr
  336.     ."    and DA." cr scr
  337.     ."  • Choosing “Save” from the menu confirms your" scr
  338.     ."    choice before overwriting the dictionary." cr scr
  339.     ."                                ( continued ... )"
  340.     .arrows ;
  341.  
  342. : P14  cls scr
  343.     ." Notes, continued ..." cr scr
  344.     ."  • 68040's instruction cache must be disabled" scr
  345.     ."    to correctly compile code." cr scr
  346.     ."  • The floating point interpreter will attempt" scr
  347.     ."    to convert any undefined token to a number." scr
  348.     ."    If the token begins with a number, it will" scr
  349.     ."    be converted causing unexpected results." cr scr
  350.     ."  • Numerous code tightening and speed up" scr
  351.     ."    enhancements have been made."
  352.     .arrows ;
  353.  
  354. : P15  cls scr
  355.     ." Packing list for Pocket Forth, release 6.4:" scr scr
  356.     ."  • The application, Pocket Forth version 0.6.4" scr
  357.     ."  • The desk accessory, PocketDA version 1.6.3" cr scr
  358.     ."  Text files:" scr
  359.     ."  • The Manual parts 1 and 2 (use "
  360.      4 !face ." TeachText" 0 !face ." )" scr
  361.     ."  • The Glossary of Pocket Forth words" scr
  362.     ."  • Source code with assembly instructions" scr
  363.     ."     and an assembly script for Frontier." scr
  364.     ."  • Source and Manual Addendum for the DA." cr scr scr
  365.     ."                                ( continued ... )"
  366.     .arrows ;
  367.  
  368. : P16  cls scr
  369.     ."  • Example folder:           (Packing list cont.)" cr scr
  370.     ."                                   create this application" bcr
  371.     ."      Reader" scr
  372.     ."                                   the guts of a text editor" bcr
  373.     ."      TextEdit" scr
  374.     ."                                   the Sieve of Erastothanes" bcr
  375.     ."      Sieve" scr
  376.     ."                                   demonstrate them" bcr
  377.     ."      Window&Menu" scr
  378.     ."                                   read and write ASCII data files" bcr
  379.     ."      DataFiles" scr
  380.     ."                                   floating point trig. functions" bcr
  381.     ."      SANETrig" scr
  382.     ."                                   16/32 bit math functions" bcr
  383.     ."      IntegerTrig" scr
  384.     ."                                   QuickDraw routines with demo" bcr
  385.     ."      Graphics" scr
  386.     ."                                   an RPN scientific calculator" bcr
  387.     ."      Calculator" cr scr scr
  388.     ."                                ( continued ... )"
  389.     .arrows ;
  390.  
  391. : P17  cls scr
  392.     ."  • Extension folder:          (Packing list cont.)" cr scr
  393.     ."                                    Make Pocket Forth mostly" bcr
  394.     ."      Starting folder" scr
  395.     ."                                    compatable with "
  396.                                           4 !face  ." Starting" bcr
  397.     nfont 2 !face ."     ATTENTION" 0 !face sfont scr
  398.     ."                                    " 4 !face  ." Forth"
  399.                                           0 !face  ."  by Leo Brodie!" bcr
  400.     nfont 2 !face ."      BEGINNERS!" 0 !face sfont cr scr
  401.     ."                                    A folder with new event" bcr
  402.     ."      Apple Events" scr
  403.     ."                                    definitions and interface files for" scr
  404.     ."                                    Frontier, HyperCard & AppleScript."
  405.     cr scr
  406.     ."                                    A library of utility routines." bcr
  407.     ."      Misc" cr scr
  408.     ."                                    The Forth Vendors Group" bcr
  409.     ."      fvgFloatingPoint" scr
  410.     ."                                    floating point standard."
  411.     128 94 161 127 irect !rect  ( set icon rect )
  412.     128 irect .icon  ( draw the icon )
  413.     .arrows ;
  414.  
  415. : P18  cls scr
  416.     ."  • Contributions:             (Packing list cont.)" cr scr
  417.     ."                                    Case and object oriented" bcr
  418.     ."      From Peters" scr
  419.     ."                                    extensions to Pocket Forth." cr scr
  420.     ."                                    A fractal drawing program." bcr
  421.     ."      From Gates" scr
  422.     ."                                    Double click on the Mandelbrot" scr
  423.     ."                                    icon to run the program." cr scr
  424.     ."                                    Two programs, some useful" bcr
  425.     ."      From Consuegra" scr
  426.     ."                                    extensions, and a manual" scr
  427.     ."                                    formatted for printing." cr scr lcr
  428.     ."                                ( continued ... )"
  429.     .arrows ;
  430.  
  431. : P19  cls scr
  432.     ."  • Contributions cont’d:      (Packing list cont.)" cr scr
  433.     ."                                    The manual in Japanese." bcr
  434.     ."      From Nagasawa" cr scr
  435.     ."                                    Forth written in Forth." bcr
  436.     ."      From Webb" cr scr
  437.     ."     Other files from M. Roberts, R. Chuo and others" scr
  438.     ."     are included.  Thanks to all of you!" cr scr
  439.     ."  • Programs folder:" scr
  440.     ."     This folder contains two programs I have previously" scr
  441.     ."     released.  The full source code for Bezier, a DA," scr
  442.     ."     and Rhine, an application are included."
  443.     .arrows ;
  444.  
  445. : P20  cls scr
  446.     ."     If you find a bug, need help, or want to talk" scr
  447.     ."    about this, write. I'd like to hear from you and" scr
  448.     ."    I'll attempt to answer your mail." afont ." *" sfont  cr scr
  449.     ."    Do not send any money, Pocket Forth is free!" cr scr
  450.     ."    Contact me at any of the following addresses:" scr
  451.     ."      Preferred email     heilman@pc.maricopa.edu" scr
  452.     ."      CompuServe           [70566,1474]" scr
  453.     ."      AOL                         cheilman" scr
  454.     ."      U.S. Mail                 PO box 8345" scr
  455.     ."                                     Phoenix AZ 85066-8345" cr lcr
  456.     ."    " afont ." * Be patient though, it takes some time "
  457.     ." for me to make up an answer." lcr sfont
  458.     ."       " afont ." If you haven't heard from me in 2 weeks, "
  459.     ." write again.  Thanks." sfont
  460.     .aarrow ;
  461.  
  462. \ page list
  463. variable PWHICH  0 pwhich !  ( page-1 to be drawn )
  464. 19 constant PNO  ( number of pages-1 )
  465. create PLIST  ( ordered list of routines or "pages" )
  466.     ' p1 ,  ' p2 ,  ' p3 ,  ' p4 ,
  467.     ' p5 ,  ' p6 ,  ' p7 ,  ' p8 ,
  468.     ' p9 ,  ' p10 , ' p11 ,  ' p12 ,
  469.     ' p13 ,  ' p14 ,  ' p15 ,  ' p16 ,
  470.     ' p17 ,  ' p18 ,  ' p19 ,  ' p20 ,
  471.  
  472. ( update, menu, button and idle handlers )
  473. : DOUP  pwhich @ 2* plist + @ execute ;  ( draw the pwhichth page )
  474. : DON ( n -- ) pwhich ! doup ;  ( go to nth page )
  475. : DOAFT  pwhich @ 1 - 0 max don ;  ( decrement pwhich )
  476. : DOFOR  pwhich @ 1+ pno min don ;  ( increment pwhich )
  477. : DOFIRST  0 don ;  ( go to first page )
  478. : DOLAST  pno don ;  ( go to last page )
  479. : DONEW 4 don ;  \ go to "whats new" page
  480. : DOBUG 10 don ;  \ go to "bug fixes" page
  481. : DONOTE 12 don ;  \ go to "notes" page
  482. : DOPACK 14 don ;   \ go to "packing list" page
  483.  
  484. : STOP  -bird bye ; ( stop animating )
  485.  
  486. \ menu list
  487. create GMENU ' dofirst , ' doaft , ' dofor , ' dolast ,
  488.    ' null ,  ' donew ,  ' dobug ,  ' donote ,  ' dopack ,  ' dolast ,
  489. create FMENU ' stop ,
  490. create MBAR fmenu ,  18 +md @ 2+ @ ,  gmenu ,
  491. 2variable GMENUH  0 0 gmenuh 2!  ( holder for goMenuHandle )
  492. ' beep  18 +md @  ( get pointer to menu list )
  493.         2+ @  ( get pointer to Edit menu from menu list )
  494.         8 + !  ( set paste handler to beep )
  495.  
  496. : +MENU ( -- ) ( Turn the new menu on.)
  497.     0 0 2>r 4 >r ,$ A9BF  ( _GetRMenu )
  498.     2r> 2dup 2>r 0 >r ,$ A935  ( _InsertMenu )
  499.     gmenuh 2!  ,$ A937 ;  ( _DrawMenuBar )
  500.  
  501. : DOBUTT  ( -- ) ( button handler )
  502.     @mouse apoly ?phit IF apoly 2@ 2>r ,$ A8C9 doaft ELSE
  503.       @mouse fpoly ?phit IF fpoly 2@ 2>r ,$ A8C9  dofor 
  504.     THEN  THEN ;
  505.  
  506. \ Idle procedure
  507. variable TLAST  0 tlast !  ( timer )
  508. 10 constant DELAY
  509. : TICKS ( -- n ) 364 0 l@ ;
  510. : ?TIME ( -- flags ) ( true if 1/delay seconds has elapsed )
  511.     ticks tlast @ - abs delay > ;
  512. : DOIDLE  ( do the first page animation )
  513.     pwhich @ 0= IF  ( if its the title page )
  514.       ?time IF ticks tlast !  animate
  515.     THEN  THEN ;
  516.  
  517. \ startup procedure
  518. : START  sfont   \ Set to 12 point Chicago
  519.     2 >r ,$ A889  \ SrcXor _TextMode
  520.     +apoly +fpoly       \    This is stuff that must
  521.     +menu  +bird         \   be set up at runtime,
  522.     128 +icon  129 +icon  \  because it uses handles.
  523.     BEGIN ?terminal drop AGAIN ;  ( event loop )
  524.  
  525. \ This is event handlers and data to set up when this is loaded.
  526. ' doup    14 +md !  \ set update handler
  527. ' dobutt  16 +md !  \ set button handler
  528.   mbar    18 +md !  \ set the menu handlers
  529. ' doidle  20 +md !  \ set idle handler
  530. ' stop    22 +md !  \ set quit handler
  531. ' start   26 +md !  \ set startup handler
  532. ' null   136 +md !  \ disable Apple Events
  533. 450 250   8 +md 2!  \ set window size
  534.  
  535. save  bye
  536.