       ͻ
        Lesson 5 Part 100  F-PC 3.5 Tutorial by Jack Brown 
       ͼ

                  Ŀ
                    Check Book Case Study 
                  

It is time for another case study.  This time we have a medium sized
menu driven program which will assist in balancing your check book.
Capture the next few messages and edit out the headers and save the code
in the file CHKBOOK.SEQ.  Run the program and study each and every word
and procedure.  You are going to have to make some major modifications
to this program for your first project.

\ File Name    : CHKBOOK.SEQ
\ Program Name : Check Book
\ Author       : Jack W. Brown

\ Original Date: July 25, 1988 for PF Forth
\ Last Modified: March 7, 1988 for F-PC 2.25

\ Function     : Balance your check book

\ Required     :
\ Support Files: DMULDIV.SEQ and DMATH.SEQ
\              : JBINPUT.SEQ from JBINPUT.ZIP

\ Usage        : Fload file and type  MAIN, follow instructions
\              : it won't break.

\ Overview     : A simple menu driven program that illustrates how
\              : you can program dollars and cents using single
\              : integers.  You must also have your ANSI.SYS driver
\              : installed in your CONFIG.SYS file.
\              : BIG BOX COMMENTS JUST LIKE " C " PROGRAMMERS USE!!

\ Revision History
\ JWB 25-07-88 Original PF-Forth version created.
\ JWB 07-03-89 Modified for F-PC 2.25 and Tutorial
\ JWB 16-04-90 Modified for F-PC 3.50
\ Re define comment to end of line so we can use "C" type comments.
: /* [COMPILE] \ ; IMMEDIATE

/* ************************************************************ */
/*                                                              */
/* For F-PC 2.25  with ANSI.SYS installed in your CONFIG.SYS    */
/*                                                              */
/* Program: Checkbook - Implement simple checkbook program.     */
/*                      FORTH version.                          */
/* Date: July 25, 1988                                          */
/*                                                              */
/* ************************************************************ */

\ FLOAD DMULDIV.SEQ
\ FLOAD DMATH.SEQ
\ FLOAD JBINPUT.SEQ

VARIABLE BAL_DOLLARS            /* Checkbook balance dollar amount */
VARIABLE BAL_CENTS              /* Checkbook balance cents amount  */
VARIABLE TR_DOLLARS             /* Transaction dollar amount       */
VARIABLE TR_CENTS               /* Transaction cents amount        */
VARIABLE VALID                  /* Valid return code from scanf    */
VARIABLE OLD_DOLLARS            /* Initial dollar balance          */
VARIABLE OLD_CENTS              /* Initial cents balance           */
VARIABLE CHK_DOLLARS            /* Total check dollars             */
VARIABLE CHK_CENTS              /* Total check cents               */
VARIABLE CHK_COUNT              /* Number of checks this session   */
VARIABLE DEP_COUNT              /* Number of deposits this session */
VARIABLE DEP_DOLLARS            /* Total deposit dollars           */
VARIABLE DEP_CENTS              /* Total deposit cents             */
VARIABLE TEST

/* ************************************************************ */
/*                                                              */
/* Function:    scan_for_int  - scan input stream for a single  */
/*                              integer.                        */
/*                                                              */
/* Date: July 25, 1988                                          */
/*                                                              */
/* Interface:    SCAN_FOR_INT(-- n )                            */
/*                                                              */
/* ************************************************************ */

: SCAN_FOR_INT     ( --   num )   #IN ;


/* ************************************************************ */
/* Function: HBAR     Draws a horizontal bar on display         */
/*                                                              */
/* Date: July 25, 1988                                          */
/*                                                              */
/* Interface:   HBAR ( n  --)                                   */
/*                                                              */
/* ************************************************************ */

: HBAR ( n  -- )
     0 DO ASCII = EMIT LOOP CR ;

