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.

the computer or entered by the user. This value is placed into<br />

the variable C. If C is less than 0, then this is the signal we<br />

are using to indicate we wish to go back to the Main Menu.<br />

This is taken care of in line 1907. We are not going to<br />

permit check numbers higher than 9999, since we do not have<br />

much room on our 40 character screen. If the number is too<br />

large, we go to line 1913 which prints the necessary message,<br />

takes us out of automatic check numbering if we were in that<br />

mode, decrements the screen line number and starts us over<br />

again at line 1904.<br />

Otherwise, we place the value of C in our array variable<br />

CN%(R), and get ready to print the check number on the<br />

screen. We do this by first placing our cursor at HTAB 4 and<br />

clearing the line to the right of the cursor by the subroutine in<br />

line 25.<br />

25 PRINT ....;: CALL - 868: RETURN<br />

Now get ready to print the check number right justified.<br />

Set the column (T%) to 7. Then jump to the subroutine for<br />

right justification starting at line 50.<br />

50 POKE 36,T% - 1: IF SG = - 1 AND PR<br />

THEN CALL - 1008<br />

51 FOR A = 1 TO 4: IF ABS (C) > =<br />

INT (10 " A) THEN CALL - 1008<br />

52 NEXT A: IF SG = - 1 THEN INVERSE:<br />

IF PR THEN PRINT "-";<br />

53 PRINT C;: RETURN<br />

The cursor is placed at T%-1 by a POKE 36 to that value.<br />

This is the first place we run up against the flag PRo This<br />

flag is used to indicate whether or not we are printing to the<br />

printer or not.<br />

If this subroutine is called by a routine which is printing a<br />

number on a printer, and the number is negative as indicated<br />

by the variable SG, then we need to backspace one space to<br />

make room for the negative sign that will have to be printed<br />

on the paper (since we ean not print in inverse mode as we can<br />

on the screen to indicate negatives). The backspace is<br />

accomplished with a CALL -1008.<br />

Now we examine C. If C is equal to or larger than 10, we<br />

backspace one space. If C is equal to or larger than 100, we<br />

backspace another space. And so on up to 10 to the 4th<br />

power. We do not use numbers as large as 100,000 in this<br />

program. Now, if the number is negative, we will print it in<br />

inverse. If we are using a printer, we will print a negative<br />

sign (-). Then we will print the number without issuing a<br />

line feed (note the semi-colon after the C in line 53), and<br />

RETURN to line 1911, which immediately takes us to line<br />

1916.<br />

1916 HTAB 8:T$ = ....:E$ = ....: PRINT "?";<br />

1917 IF Ml > 0 THEN HTAB 1: VTAB 24:<br />

PRINT "HIT FOR" +<br />

MIS +" (DEFAULT)";: CALL - 868:<br />

HTAB 9: VTAB L%: GOSUB 25<br />

1919 GET ES: IF E$ = CHR$ (13) THEN 1924<br />

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

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

B = B-1: GOTO 1904<br />

1921 GOSUB 5<br />

1922 GOTO 1919<br />

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

C = Ml: GOTO 1930<br />

1925 IF C < 0 THEN 1500<br />

1926 IF C = 0 OR C > 12 THEN GOSUB 25:<br />

GOTO 1916<br />

1927 01 = 0: FOR I =1 TO 12: READ Ml,MIS:<br />

IF Ml = C THEN I = 12: NEXT: GOTO 1930<br />

1928 NEXT<br />

1929 GOSUB 25: GOTO 1919<br />

1930 RESTORE: HTAB 8: CALL - 958:<br />

T% = 10: GOSUB 50: PRINT "f';:MO%(R)<br />

= C:Ml = C:T% = 12: GOSUB 26<br />

WHAT MONTH IS IT?<br />

Next we get ready to enter the month. After clearing some<br />

temporary string variables we will be using and printing our<br />

question mark in the proper place, we print the month that we<br />

have put into MI$ at the bottom of the screen and notify the<br />

user that if that is the month he wishes to enter, all he has to<br />

do is press . If that is what the user docs, the<br />

program GOES TO line 1924. Otherwise we start creating<br />

the string T$ by adding the character GOTten in line 1919 to<br />

the latest version of TS. (This is called "concatenation", for<br />

those of you who like big words.)<br />

Now ifthe last character GOTten was a backspace and that<br />

makes T$ one character long, the user is trying to backspace<br />

to the previous field. So we decrement B and go back to line<br />

1904. Otherwise we GO to the SUBroutine at line 5.<br />

5 IF ASC (ES) < 32 AND ASC (E$) < >8<br />

THEN RETURN<br />

6 IF E$ = CHR$ (8) AND LEN (TS) = 2<br />

THEN 1'$ = ....<br />

7 IF E$ = CHR$ (8) AND LEN (TS) > 2<br />

THEN 1'$ = LEFfS (1'$, LEN (1'$) - 2)<br />

10 RETURN<br />

Here we examine E$ to sec if it is a valid character, not a<br />

control character and not a backspace. If it is we return to line<br />

1922 which takes us back to line 1919. Next we provide for<br />

the case when T$ consists of two characters, the last of which<br />

is a backspace. This makes T$ a null string. Finally, we<br />

provide for the case when T$ consists of more than two<br />

letters, the last one of which is a backspace. This makes T$<br />

equal to what it used to be minus the last two characters, the<br />

backspace and the character backspaced over. OK?<br />

We continue getting characters in line 1919 until<br />

is pressed, at which time the program jumps to<br />

line 1924. Remember of course, that the user is INPUTing<br />

the number of the month here.<br />

The string 1'$ is changed into a number by the C =<br />

VAL(T$) expression in line 1924. Now if was<br />

the only key pressed, the length of TS will be zero, and C<br />

takes on the value stored in MI, and we can go directly to line<br />

1930. Otherwise, we have to check the value of C to make<br />

sure a legitimate number was entered. Again, if C is less than<br />

0, this is the clue the user gives the computer to return to the<br />

Main Menu. If C is 0 or if C is greater than 12, then we have<br />

to clear the line and start allover again at line 1916.<br />

Otherwise, we can READ the DATA in line 1700 to match<br />

the number of the month with the name of the month, and<br />

then print the number of the month right justified from<br />

T%=10 (line 1930).<br />

1700 DATA 1,"JANUARY",2,"FEBRUARY",3,<br />

"MARCH" 4 "APRIL" 5 "MAY" 6 "JUNE"<br />

, , , , , , contd.<br />

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

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

Saved successfully!

Ooh no, something went wrong!