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.

7,"JULY",8,"AUGUST',9,"SEPTEMBER",<br />

lO,"OCTOBER",II,"NOVEMBER",12,<br />

"DECEMBER"<br />

1701 DATA 13<br />

Finally, we print a slash to separate the month from the<br />

date, put C into the current array variable, MO%(R), and make<br />

sure that MI holds the value of C.<br />

1932 IF NOT D 1 THEN 1935<br />

1933 HfAB 1: VTAB 24: PRINT "HIT<br />

FOR ";01;" (DEFAULn";: CALL - 868<br />

1935 1'$ = '''':E$ = "It: HfAB 12: VTAB L%:<br />

PRINT "?";: GOSUB 25<br />

1936 GET E$: IF E$ = CHR$ (13) THEN 1941<br />

1937 1'$ = 1'$ + E$: PRINT E$;: IF E$ =<br />

CHR$ (8) AND LEN (1'$) =1 THEN 1916<br />

1938 GOSUB 5<br />

1939 GOTO 1936<br />

1941 C = VAL (1'$): IF LEN (1'$) = 0 THEN<br />

C=Dl<br />

1942 HfAB 12: GOSUB 25: IF C < lOR<br />

C > 31 THEN 1935<br />

1943 T% = 13: GOSUB 50:DT%(R) =C:01 =C<br />

The routine for entering the date is pretty much the same<br />

idea If this is our frrst time through, we don't have a default<br />

value for the date, so we can jump directly to the input routine<br />

at line 1935. (You may have noticed we set Dl equal to 0 in<br />

line 1927 which we would only encounter if we were establishing<br />

a new month for our record).<br />

1945 T% = 14: GOSUB 26: GOSUB 30<br />

1949 VTAB L%: HfAB T%: CALL - 958:<br />

PRINT" ";1'$;: IF LEFTS (1'$,1) > <<br />

"#" THEN 1955<br />

1950 IF S2 THEN SI = SI - 1.<br />

30 1'$ = "":E$ ="": PRINT "?";: IF LEN (Vl$)<br />

> 0 THEN HfAB 1: VTAB 24: PRINT "illT<br />

FOR " + Vl$ + "<br />

(DEFAULn";: CALL - 868: HfAB 15:<br />

VTAB L%: GOSUB 25<br />

31 GET ES: IF ES = CHRS (13) THEN 36<br />

32 1$ = 1$ + ES: PRINT ES;: IF ES = CHRS<br />

(8) AND LEN (T$) = 1 THEN GOTO 1932<br />

33 GOSUB 5<br />

35 GOTO 31<br />

36 IF LEN (1'$) = 0 THEN 1$ =Vl$<br />

37 IF LEN (1'$) > 12 THEN 1$ = LEFTS (1'$,12)<br />

38 VENS(R) = 1$:VIS =1'$:SG =I: IF<br />

LEFI'$ (T$,I) = "#" THEN SG = - 1<br />

39 RETURN<br />

Next, we input the data for the "TO/FROM WHOM"<br />

column. Here again we use the same principle as bcfore. The<br />

only thing to notice here is that we restrict the lcngth of the<br />

string to 12 characters, and we use the frrst character of this<br />

field to indicate whether the item is income or expense. If it<br />

is income, we use the "#" sign as the first character and make<br />

SG equal to -1. We also decrement the check number by one<br />

if we are automatically numbering the checks. This means, of<br />

course, that the user will have to enter deposits before<br />

withdrawals when using the automatic check numbering mode<br />

so that the withdrawal will have the same check number as the<br />

deposit<br />

40<br />

1955 T% = 30: HfAB T%: GOSUB 60:<br />

HfAB T%: CALL - 958:T% = 32:AMT(R)<br />

=C: GOSUB 70<br />

60 1$ ="":ES ="": PRINT "?";: IF Q% =1<br />

THEN CALL - 868<br />

61 GET E$:1'$ =1'$ + E$: IF ES = CRRS (8)<br />

AND LEN (1'$) =1 THEN GOTO 58<br />

58 IF Q% < > 1 THEN CALL - l008:GOTO 60<br />

59 GOTO 1945<br />

62 PRINT E$;: GOSUB 5<br />

64 IF E$ = CHRS (13) THEN C = VAL (1'$):<br />

GOT066<br />

65 GOTO 61<br />

66 GOSUB 26: IF C < 0 THEN SG = - 1<br />

67 C = ABS (C): IF C < 99999 THEN C =<br />

C .. SG:SG = 1: RETURN<br />

68 HfAB 1: VTAB 24: PRINT "CAN'T<br />

ACCEPT A NUMBER THAT BIG";: VTAB<br />

L%: HfAB T%: GOTO 60<br />

70 IF C < 0 THEN SG =-1<br />

71 IF SG =-1 THEN INVERSE :C = ABS (C):<br />

GOSUB 72: RETURN<br />

72 X =C:C = !NT (C): GOSUB 50<br />

75 1'$ ="." + RIGHTS (STRS (!NT «X +<br />

1.0001) .. 1(0»,2)<br />

77 PRINT1'$;<br />

78 NORMAL:1'$ = STRS (C) + 1'$:C =<br />

VAL (1'$)" SG:SG = 1: RETURN<br />

HOW MUCH?<br />

Now for the AMOUNT column. After setting up our tabs<br />

we GOSUB 60 which is the routine for INPUTing amounts.<br />

IfQ%=I, that is, we are in the ENTER DATA mode, then we<br />

clear the entire line from the cursor to the right. Then we go<br />

to the GET routine. If the frrst character of 1'$ is a backspace,<br />

then we GOTO 58. If we are in other than the ENTER<br />

DATA mode, we just backspace and then go back to the GET<br />

routine. Otherwise, the backspace takes us to the previous<br />

field (TO/FROM WHOM, line 1945).<br />

After hitting we set C to the VALue of 1$.<br />

Then we test to make sure the number is not too large, and<br />

then return to line 1955. After clearing the screen from the<br />

cursor down, we reset the tab to prepare for right decimal<br />

justification, set the array variable equal to C, and GOSUB<br />

70.<br />

The routine at 70 is the one we use to ensure that all our<br />

dollar amounts are printed with two decimal places and with<br />

the decimals aligned. First we see if the amount is negative.<br />

If it is, we set SG equal to -1. If SG is -1 because of line 70,<br />

or if it already was -1 because we set it this way because we<br />

are dealing with a deposit, we print the number in inverse on<br />

the screen. Now all we have to worry about is the absolute<br />

value of C, that is, C without a plus or a minus sign, so we<br />

do this with the substitution equation C =ABS (C). Next we<br />

will be doing some operations on C, so we want to save its<br />

value in the variable X. First we will just use the part of C<br />

to the left of the decimal point, the INTeger of C. We will<br />

right justify that part of the number by using the subroutine<br />

at line 50.<br />

Now let us look at line 75. Taking the substitution<br />

equation for TS from the inside of the parentheses to the<br />

contd.<br />

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

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

Saved successfully!

Ooh no, something went wrong!