home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / tutor / l5p100 < prev    next >
Text File  |  1990-07-15  |  5KB  |  100 lines

  1.        ╔════════════════════════════════════════════════════╗
  2.        ║ Lesson 5 Part 100  F-PC 3.5 Tutorial by Jack Brown ║
  3.        ╚════════════════════════════════════════════════════╝
  4.  
  5.                   ┌────────────────────────┐
  6.                   │  Check Book Case Study │
  7.                   └────────────────────────┘
  8.  
  9. It is time for another case study.  This time we have a medium sized
  10. menu driven program which will assist in balancing your check book.
  11. Capture the next few messages and edit out the headers and save the code
  12. in the file CHKBOOK.SEQ.  Run the program and study each and every word
  13. and procedure.  You are going to have to make some major modifications
  14. to this program for your first project.
  15.  
  16. \ File Name    : CHKBOOK.SEQ
  17. \ Program Name : Check Book
  18. \ Author       : Jack W. Brown
  19.  
  20. \ Original Date: July 25, 1988 for PF Forth
  21. \ Last Modified: March 7, 1988 for F-PC 2.25
  22.  
  23. \ Function     : Balance your check book
  24.  
  25. \ Required     :
  26. \ Support Files: DMULDIV.SEQ and DMATH.SEQ
  27. \              : JBINPUT.SEQ from JBINPUT.ZIP
  28.  
  29. \ Usage        : Fload file and type  MAIN, follow instructions
  30. \              : it won't break.
  31.  
  32. \ Overview     : A simple menu driven program that illustrates how
  33. \              : you can program dollars and cents using single
  34. \              : integers.  You must also have your ANSI.SYS driver
  35. \              : installed in your CONFIG.SYS file.
  36. \              : BIG BOX COMMENTS JUST LIKE " C " PROGRAMMERS USE!!
  37.  
  38. \ Revision History
  39. \ JWB 25-07-88 Original PF-Forth version created.
  40. \ JWB 07-03-89 Modified for F-PC 2.25 and Tutorial
  41. \ JWB 16-04-90 Modified for F-PC 3.50
  42. \ Re define comment to end of line so we can use "C" type comments.
  43. : /* [COMPILE] \ ; IMMEDIATE
  44.  
  45. /* ************************************************************ */
  46. /*                                                              */
  47. /* For F-PC 2.25  with ANSI.SYS installed in your CONFIG.SYS    */
  48. /*                                                              */
  49. /* Program: Checkbook - Implement simple checkbook program.     */
  50. /*                      FORTH version.                          */
  51. /* Date: July 25, 1988                                          */
  52. /*                                                              */
  53. /* ************************************************************ */
  54.  
  55. \ FLOAD DMULDIV.SEQ
  56. \ FLOAD DMATH.SEQ
  57. \ FLOAD JBINPUT.SEQ
  58.  
  59. VARIABLE BAL_DOLLARS            /* Checkbook balance dollar amount */
  60. VARIABLE BAL_CENTS              /* Checkbook balance cents amount  */
  61. VARIABLE TR_DOLLARS             /* Transaction dollar amount       */
  62. VARIABLE TR_CENTS               /* Transaction cents amount        */
  63. VARIABLE VALID                  /* Valid return code from scanf    */
  64. VARIABLE OLD_DOLLARS            /* Initial dollar balance          */
  65. VARIABLE OLD_CENTS              /* Initial cents balance           */
  66. VARIABLE CHK_DOLLARS            /* Total check dollars             */
  67. VARIABLE CHK_CENTS              /* Total check cents               */
  68. VARIABLE CHK_COUNT              /* Number of checks this session   */
  69. VARIABLE DEP_COUNT              /* Number of deposits this session */
  70. VARIABLE DEP_DOLLARS            /* Total deposit dollars           */
  71. VARIABLE DEP_CENTS              /* Total deposit cents             */
  72. VARIABLE TEST
  73.  
  74. /* ************************************************************ */
  75. /*                                                              */
  76. /* Function:    scan_for_int  - scan input stream for a single  */
  77. /*                              integer.                        */
  78. /*                                                              */
  79. /* Date: July 25, 1988                                          */
  80. /*                                                              */
  81. /* Interface:    SCAN_FOR_INT(-- n )                            */
  82. /*                                                              */
  83. /* ************************************************************ */
  84.  
  85. : SCAN_FOR_INT     ( --   num )   #IN ;
  86.  
  87.  
  88. /* ************************************************************ */
  89. /* Function: HBAR     Draws a horizontal bar on display         */
  90. /*                                                              */
  91. /* Date: July 25, 1988                                          */
  92. /*                                                              */
  93. /* Interface:   HBAR ( n  --)                                   */
  94. /*                                                              */
  95. /* ************************************************************ */
  96.  
  97. : HBAR ( n  -- )
  98.      0 DO ASCII = EMIT LOOP CR ;
  99.  
  100.