home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / forth / 3792 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  1.7 KB

  1. Path: sparky!uunet!usc!wupost!waikato.ac.nz!canterbury.ac.nz!lincoln.ac.nz!wronz.org.nz!mentink
  2. Newsgroups: comp.lang.forth
  3. Subject: This is NOT 'Documenting'.. yuk
  4. Message-ID: <1993Jan8.140235.91@wronz.org.nz>
  5. From: mentink@wronz.org.nz
  6. Date: 8 Jan 93 14:02:35 +1300
  7. Lines: 44
  8.  
  9.     Hi all you eforth-ers,
  10.  
  11.           Can anyone help, the standard EFORTH word-set includes the word
  12. NUMBER? which converts a number string entered interactivly by the user.
  13. Although it accepts hex numbers e.g $4000, it does not conform to the
  14. usual FORTH and allow you to enter a double number e.g 123.45
  15.  
  16. Can anyone help by providing a modification of the EFORTH source for the
  17. word. Follows below ....... 
  18.  
  19.   Alternatively....
  20.   Provide a seperate word to allow you to enter a double number on the
  21.   stack.
  22.  
  23.  
  24.   Thanks in advance.
  25.  
  26. / --------------------- Source starts here -----------------------------
  27.  
  28.  
  29. : NUMBER? ( a -- n T, a F )
  30.   BASE @ >R  0 OVER COUNT ( a 0 b n)
  31.   OVER C@ [ CHAR $ ] LITERAL =
  32.   IF HEX SWAP BYTE+ SWAP 1 - THEN ( a 0 b' n')
  33.   OVER C@ [ CHAR - ] LITERAL = >R ( a 0 b n)
  34.   SWAP R@ - SWAP R@ + ( a 0 b" n") ?DUP
  35.   IF 1 - ( a 0 b n)
  36.     FOR DUP >R C@ BASE @ DIGIT?
  37.       WHILE SWAP BASE @ * +  R> BYTE+
  38.     NEXT R@ ( ?sign) NIP ( b) IF NEGATE THEN SWAP
  39.       ELSE R> R> ( b index) 2DROP ( digit number) 2DROP 0
  40.       THEN DUP
  41.   THEN R> ( n ?sign) 2DROP R> BASE ! ;
  42.  
  43.   --------------------------------------------------------------------------
  44.     Bernie Mentink   ( Christchurch N.Z. )
  45.     email: mentink@wronz.org.nz
  46.  
  47.     Huru the guru says ......
  48.         1. T'is better to know some of the questions than all of the answers.
  49.          2. It's what you learn after you know it all that counts ....
  50.  ---------------------------------------------------------------------------
  51.  
  52.  
  53.