09.04.2013 Views

Washington Apple Pi Journal, July 1986

Washington Apple Pi Journal, July 1986

Washington Apple Pi Journal, July 1986

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

set Y equal to the value contained at memory location 222,<br />

where the error codes are stored. We have added a few more<br />

error handlers to this program compared to the other program<br />

modules. Let's go over them briefly here. Hopefully, we<br />

won't have to come back.<br />

If Y is equal to 5, that is, if the problem is simply that we<br />

have no data in the me we are attempting to use, we don't<br />

want to reset the top of the window. However, for all the<br />

other errors we do. If Y is equal to 254, that means we have a<br />

bad response to an INPUT statement. Therefore, we want to<br />

be able to give the user a second chance rather than having the<br />

program crash. So we ask for rentry of the data. The command<br />

to RESUME takes the program back to the statement in<br />

which the error occurred. This is in contrast to the CONT<br />

command which takes the program back to the instruction<br />

following the statement in which the program was stopped.<br />

As we have seen in our previous articles, Y equals 5 when<br />

there is no data in a file that we are trying to read. We will<br />

get this error if the me exists, but contains no data. That is<br />

the case here if we choose to use "DATA FILE" as the name<br />

of our data me. We will then be taken to line 150 of the<br />

program.<br />

If we choose to use another name for our data file, then it<br />

doesn't exist yet, and we will get Y equal to 6, "FILE NOT<br />

FOUND". To make sure that we didn't merely spell it wrong,<br />

we are asked if we wish to create a file with this name. If we<br />

don't, we are taken back to line 1400 for another try. If we<br />

do, then the me is created on the disk by opening and closing<br />

it with this name, and then we are taken to the Main Menu.<br />

We have seen Y equal to 77 before. This happens when<br />

we run out of memory. We have also seen Y equal to 9<br />

before. This happens when the disk is full. We have provided<br />

for Y equals 22 in this program. Y would equal 22 if a<br />

RETURN occurs without a GOSUB. Hopefully the program<br />

is designed so that the user would never get this error.<br />

However, in case the user does something completely<br />

unexpected. this error handler is provided and takes the user<br />

back to the Main Menu.<br />

Let us assume the user chose to use the default name for<br />

the data file, at hit , getting error #5, which as<br />

we saw above, would take us to line 150.<br />

150 PRINT Cl..$;FDS<br />

152 VTAB 24: FLASH: PRINT "NO<br />

DATA IN MEMORY": POKE 216,0: FOR C =<br />

1 TO 1000: NEXT C: NORMAL: GOTO 1500<br />

Line 150 closes the file we tried to OPEN in line 1415.<br />

We let the user know that there is no data in memory, and<br />

then proceed to line 1500 for the Main Menu. By the way,<br />

the POKE at memory location 216 sets the error handler back<br />

to zero, so if another error is encountered, we will need a new<br />

ONERR GOTO statement to deal with it. The old command<br />

will no longer be in effect.<br />

I think it is finally time to talk about the Main Menu.<br />

Here we will offer the user all the options they will have in<br />

using this program.<br />

THE MAIN MENU<br />

1500 POKE 34,0: HOME: PRINT TAB(9)<br />

"HOME MONEY MANAGER": PRINT<br />

1501 PRINT"l. ENTER DATA": PRINT "2.<br />

SAVE DATA": PRINT "3. SORT DATA":<br />

PRINT "4. QUIT': PRINT<br />

1502 PRINT "BUDGET": PRINT "-----":<br />

PRINT "5. PRINT BY CATEGORY/<br />

CHANGE/DELETE": PRINT "6. CLOSE<br />

OUT END OF MONTH": PRINT "7. PRINT<br />

BUDGETED CATEGORIES"<br />

1503 PRINT "8. CHANGE BUDGETED<br />

CATEGORIES": PRINT "9. SAVE<br />

BUDGETED CATEGORIES": PRINT<br />

1505 PRINT "CHECKBOOK": PRINT .. -----":<br />

PRINT "10. LIST CHECKS/CHANGE!<br />

DELETE"<br />

1506 PRINT "11. CHECKBOOK BALANCE":<br />

PRINT "12. RECONCILE TO BANK<br />

STATEMENT": PRINT" 13. DELETE<br />

RECONCILED RECORDS"<br />

1507 PRINT: INVERSE: PRINT "CLEARING<br />

GARBAGE FROM MEMORY";: X =<br />

FRE (0): HTAB 1: CALL - 958:<br />

NORMAL :PRINT "";<br />

1508 VTAB 24: HTAB 7: PRINT "HIT<br />

FOR NEXT MENU";: VTAB<br />

23: HTAB 1: INPUT "WHlCH?";CS: CALL<br />

- 958: IF CS ="" THEN 1600<br />

1509 Q% = VAL (CS): IF Q% < lOR Q% ><br />

13 THEN 1508<br />

1510 ON Q% GOTO 1800,2100,1310,900,2500,<br />

1305,1300,1300,1300,2700,1310,1310,1310<br />

1520 GOTO 1500<br />

1600 HOME: PRINT TAB(9)"HOME<br />

MONEY MANAGER": PRINT<br />

1601 PRINT "PRINT REPORTS": PRINT<br />

tI It<br />

------------<br />

1602 PRINT "14. THIS ";MD$: PRINT "15.<br />

TInS ";MSS: PRINT "16. ";ESS: PRINT "17.<br />

";YDS: PRINT "18. ";YS$<br />

1603 PRINT: PRINT<br />

"MISCELLANEOUS FUNCDONS": PRINT<br />

"-------------------": PRINT "19. SPACE<br />

REMAINING": PRINT "20. CHANGE<br />

CURRENT MONTH": PRINT "21.<br />

INITIALIZE NEW BUDGET'<br />

1604 DT$ =MS +", '" + YR$: VTAB 23:<br />

HTAB 5: PRINT "HIT <br />

FOR PREVIOUS MENU";<br />

1605 VTAB 18: HTAB 1: INPUT "WHICH?";C$:<br />

IF CS =.... THEN 1500<br />

1606 Q% = VAL (CS): IF Q% < 14 OR Q% > 21<br />

THEN 1605<br />

1607 QN% =Q% - 13<br />

1610 ON QN% GOTO 4500,1305,1305,1310,<br />

1310,800,200,1350<br />

1620 GOTO 1600<br />

The Main Menu consists of two screens. The first screen<br />

is divided into three sections. general data entry, Budget<br />

manipulation, and Check manipulation. The second screen is<br />

divided into two sections, Printing options and Miscellaneous<br />

functions. Hitting by itself switches between<br />

the two screens. The ON - GOTO command is used<br />

extensively here, but as you can see, many of the choices JtO<br />

conrn.<br />

<strong>Washington</strong> <strong>Apple</strong> <strong>Pi</strong> <strong>July</strong> <strong>1986</strong> 37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!