home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
tutor
/
l5p120
< prev
next >
Wrap
Text File
|
1990-07-15
|
3KB
|
80 lines
\ ╔════════════════════════════════════════════════════╗
\ ║ Lesson 5 Part 120 F-PC 3.5 Tutorial by Jack Brown ║
\ ╚════════════════════════════════════════════════════╝
\ Part three of CHKBOOK.SEQ
/* ************************************************************ */
/* */
/* Function: SUB_FROM_BAL - subtract dollars, cents amount */
/* from balance. */
/* */
/* Date: July 22, 1988 */
/* */
/* Interface: SUB_FROM_BAL ( dollars cents -- flag) */
/* dollars : dollar amount to be subtracted */
/* cents : cents amount to be subtracted */
/* flag = false if illeagal transaction. */
/* */
/* ************************************************************ */
VARIABLE D
VARIABLE C
: SUB_FROM_BAL ( dollars cents -- flag )
BAL_DOLLARS @ D !
BAL_CENTS @ C !
DUP C @ >
IF -1 D +! 100 C +! THEN
NEGATE C +! NEGATE D +!
D @ 0 <
IF 60 CLR_HBAR
7 DUP DUP EMIT EMIT EMIT
." You are trying to overdraw your account. You must" CR
." first make a deposit before trying to write a cheque" CR
." this large." CR
60 HBAR
FALSE
ELSE C @ BAL_CENTS ! D @ BAL_DOLLARS ! TRUE
THEN ;
: $XX.XX ( dollars cents -- )
0 <# # # ASCII . HOLD DROP #S ASCII $ HOLD #> TYPE ;
/* ************************************************************ */
/* */
/* Function WRITE_A_CHECK - Calculate new balance */
/* after check is written */
/* */
/* Date: July 25, 1988 */
/* */
/* Interface: WRITE_A_CHECK ( -- ) */
/* */
/* */
/* Notes: Calls SUB_FROM_BAL to perform the fixed point */
/* calculations. */
/* */
/* ************************************************************ */
: WRITE_A_CHECK ( -- )
40 CLR_HBAR
." Enter the amount of the check:" CR
40 HBAR
GET_DOLLARS GET_CENTS ROUND
OVER OVER
TR_CENTS ! TR_DOLLARS !
40 HBAR
SUB_FROM_BAL
IF 1 CHK_COUNT +!
TR_DOLLARS @ CHK_DOLLARS @ +
TR_CENTS @ CHK_CENTS @ +
ROUND
CHK_CENTS ! CHK_DOLLARS !
." After writing a check for: "
TR_DOLLARS @ TR_CENTS @ $XX.XX CR
." your new balance comes to: "
BAL_DOLLARS @ BAL_CENTS @ $XX.XX CR
40 HBAR
THEN ;