home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / l3p100.seq < prev    next >
Text File  |  1988-11-04  |  754b  |  34 lines

  1. \ Numeric Input using QUERY and INTERPRET and an example
  2.  
  3. \ Super simple numeric input.
  4. :  #IN ( -- n )
  5.       QUERY  INTERPRET ;
  6.  
  7. \ Input length.
  8. : GETL  ( --   l )
  9.         CR ." Enter tank length " #IN ;
  10.  
  11. \ Input width.
  12. : GETW  ( --   w )
  13.         CR ." Enter tank width  " #IN ;
  14.  
  15. \ Input height.
  16. : GETH  ( --   h )
  17.         CR ." Enter tank height " #IN ;
  18.  
  19. \ Compute volume.
  20. : .VOLUME ( l w h  -- )
  21.         * *  CR  ." Volume "  .  ." cubic feet." ;
  22.  
  23. \ Compute surface area.
  24. : .AREA   ( l w h  -- )
  25.         3DUP 5 ROLL * 2* -ROT * 2* + -ROT * 2* +
  26.         CR ." Surface area " . ." square feet." ;
  27.  
  28. \ This is the tank program with prompted input
  29. : TANK  ( -- )
  30.         GETL  GETW  GETH
  31.         3DUP  .VOLUME    .AREA ;
  32.  
  33.  
  34.