home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / forth / 3620 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  2.3 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!ub!dsinc!netnews.upenn.edu!microlab15.med.upenn.edu!user
  2. From: sorry no email address (Peters, Randolph)
  3. Newsgroups: comp.lang.forth
  4. Subject: Pocket Forth bug fix
  5. Message-ID: <sorry?no?email?address-141292094737@microlab15.med.upenn.edu>
  6. Date: 14 Dec 92 15:00:02 GMT
  7. Sender: news@netnews.upenn.edu
  8. Followup-To: comp.lang.forth
  9. Organization: Hospital of the University of Pennsylvania
  10. Lines: 37
  11. Nntp-Posting-Host: microlab15.med.upenn.edu
  12.  
  13. I came up with my own answer to a question I posted on the net a few weeks
  14. ago. Basically, for users of Pocket forth, there is  a problem with the
  15. word interpret (which interprets the contents of the text input buffer).
  16. Specifically, you can fill the text input buffer, but you can't reset the
  17. input stream easily because there is no user variable to mark current
  18. position in the input stream. I have come up with a simple fix:
  19.  
  20. : 0>is ( -- ) ( resets the input stream to the text input buffer )
  21.      tib            ( -- buffer.addr )
  22.      a>r            ( single --     r: -- double )
  23.      2r>            ( -- double.length.buffer.addr    r: -- )
  24.      ,$ 285E        ( compile inline code for MOVEA.L [A6]+, A4 )
  25.      ; macro        ( in pocket forth, the top of the parameter stack )
  26.                     ( is in A6 and the absolute position of the text  )
  27.                     ( input buffer in memory is in A4 )
  28.  
  29. ( example of usage of the above )
  30. : query   tib 80 32 fill   ( empty the tib)
  31.           0>is             ( reset the input stream pointer)
  32.           tib 80 expect interpret ." hello" ;
  33.  
  34. This only solves one problem; now text can be transferred to the input
  35. buffer
  36. and correctly interpreted. Afterwards, however, control does not return to
  37. the
  38. word in which 'interpret' is contained. "hello" would never appear on the
  39. display. This is because interpret empties out the return stack and the
  40. parameter stack ( arrgh! ). Is this standard (for this question, I mean F83
  41. or MMSFORTH standard) behavior for this word? And is there any way to patch
  42. this behavior?
  43.  
  44. Comments and insight appreciated.
  45.  
  46.                                  Randolph Peters
  47.                                  Suite C, 3rd Floor Silverstein
  48.                                  Hospital of the University of Pennsylvania
  49.                                  34th and Spruce Streets, Phila PA 19104
  50.