Thursday, August 16, 2012

Oddities & idiosyncrasies of old code

Since I last posted, I've been digitizing the listings from Rainbow Magazine (a magazine exclusively for the TRS-80 Color Computer, a 6809-based system that I have a particular fondness for).  This is part of a long-running project of mine to gather and organize as much 8-bit material as possible, with a particular emphasis on preserving source code and amateur/hobbyist content.  I plan to write more about this project in the future and would love for it to become a genuine online museum someday.

What prompted this post, though, is a program from Rainbow's second issue (August 1981) that epitomizes part of what I'm getting at when I talk about the fascinating weirdness of programs from the early microcomputer age.  The program is a simple one: just a short application that produces loan amortization schedules (the code is at the end of the post).  It's the error handling that's special; when you're asked whether the payment schedule is based on months or years, here's the screen you get if you enter the wrong input:


The code that produces this screen takes up about 10% of the program.  No other input is validated at all, and the error message isn't even telling the truth: any input starting with "M" is taken as "MONTH", and any input starting with "Y" is taken as "YEAR".

I haven't got the slightest idea what motivated the author to devote a substantial chunk of a program in a magazine to an error screen that berates the user like this, but it's also not exactly rare for the time.  It's silly and unprofessional and you're not likely to see the like these days, but it's also thoroughly endearing and a reminder that behind the code was a person, every bit of as much as bundle of contradictions and neuroses as the rest of us.  And that's why I think it deserves to be preserved as a record of that computing culture.

(Code below the cut.)



3 '    ***********************
4 '    *   AMORT   PROGRAM   *
5 '    *  (c) FALSOFT, 1981  *
6 '    ***********************
10 C=0:CLS
12 PRINT "   THIS PROGRAM WILL GENERATE    AN AMORTIZATION SCHEDULE FOR    MOST COMMON LOANS."
13 PRINT:PRINT ">PLEASE FOLLOW DIRECTIONS BELOW<"
14 PRINT STRING$(32,"=")
15 INPUT "FIRST, WE NEED TO KNOW HOW MUCH    YOU WANT TO BORROW. THIS IS     CALLED THE  principal.  WHAT    IS THE PRINCIPAL";P
16 CLS:PRINT:PRINT
17 PA=P
20 INPUT "NOW, WE MUST KNOW THE NUMBER OF    periods THE LOAN WILL RUN.      IF YOU WISH TO ENTER THE        PERIODS BY MONTH, TYPE IN       THE WORD 'MONTH.' IF ITS        YEARS, TYPE IN 'YEAR.' WHICH     IS IT";A$
21 IF LEFT$(A$,1)="M" THEN 270
22 IF LEFT$(A$,1)="Y" THEN 260
23 GOTO250
30 CLS:PRINT:PRINT
31 INPUT "LASTLY, WE NEED TO KNOW WHAT       INTEREST RATE YOU WILL BE       CHARGED ON THE LOAN.  WHAT      IS THE RATE";R
32 INPUT "  DO YOU WANT A PRINTOUT";PO$:IF LEFT$(PO$,1)="Y" THEN PO=1
35 CLS
40 I=R/12:I=I/100
50 T=1:FOR X=1 TO L
60 T=T*(1+I):NEXT X:T=1/T
70 T=1-T
80 M=P*I/T
90 GOSUB200
100 FOR Z=1 TO L
120 A=(INT(P*I*100+.5))/100
130 B=M-A:P=P-B
140 PRINTTAB(0);:PRINTUSING"###";Z;:IF PO THEN PRINT#-2,TAB(0);:PRINT#-2,USING"###";Z;
142 PRINTTAB(3);:PRINTUSING"###,###.##";P;:IF PO THEN PRINT#-2,TAB(3);:PRINT#-2,USING"###,###.##";P;
144 PRINTTAB(14);:PRINTUSING"#,###.##";B;:IF PO THEN PRINT#-2,TAB(14);:PRINT#-2,USING"#,###.##";B;
146 PRINTTAB(23);:PRINTUSING"#,###.##";A:IF PO THEN PRINT#-2,TAB(23);:PRINT#-2,USING"#,###.##";A
160 Q=Q+1:C=C+1:AT=AT+A:NEXT Z
165 GOTO300
170 END
200 CLS:MA=M+.005:MA=INT(MA*100)/100:IF PO THEN PRINT#-2,TAB(4)"AMORTIZATION SCHEDULE"
201 IF PO THEN PRINT#-2,"PAYMENTS ARE $";MA
202 IF PO THENPRINT #-2,TAB(4) "BALANCE";
204 IF PO THEN PRINT #-2,TAB(14) "PMT/PRIN";
206 IF PO THEN PRINT #-2,TAB(24) "PMT/INT"
208 PRINT"PAYMENTS ARE $";MA
210 PRINTTAB(4)"BALANCE"TAB(14)"PMT/PRIN"TAB(24)"PMT/INT"
220 RETURN
250 CLS(5):PRINT @82,"NO!";
252 PRINT @162,"NEIN!";
254 PRINT @249,"NYET!";
255 PRINT @288," NO NO NO NO NO NO NO NO NO NO"
257 PRINT@352," ";:PRINT "   YOU DID NOT FOLLOW THE       DIRECTIONS PROPERLY. ENTER      ONLY THE WORD 'YEAR' OR         THE WORD 'MONTH.' NOW, TRY      AGAIN."
258 FOR WN=1 TO 3200:NEXT WN:CLS:PRINT:PRINT:GOTO20
260 PRINT
261 INPUT "O.K., NOW WILL YOU PLEASE ENTER    THE NUMBER OF YEARS BEFORE      YOU PAY OFF THE LOAN";YR
265 L=YR*12:GOTO 30
270 PRINT
271 INPUT "ALL RIGHT, NOW WILL YOU PLEASE     ENTER THE NUMBER OF MONTHS      IT WILL TAKE TO PAY OFF THE     LOAN";L
275 GOTO 30
300 IF PO THEN PRINT#-2," ":PRINT#-2,TAB(10)"LOAN SUMMARY":PRINT#-2,TAB(10)"==== ======="
310 IF PO THEN PRINT#-2,TAB(5) "PRINCIPAL:";:PRINT#-2,USING"$$###,###.##";PA
320 IF PO THEN PRINT#-2," PERIODS:"L;:PRINT#-2, "     RATE: ";:PRINT#-2,USING"##.##";R;:PRINT#-2,"%"
330 IF PO THEN PRINT#-2,STRING$(31,"-")
340 IF PO THEN PRINT #-2,"TOTAL INTEREST: ";:PRINT#-2,USING"$$###,###.##";AT
350 IF PO THEN PRINT#-2," ":PRINT#-2," ":PRINT#-2," "

No comments:

Post a Comment