HP-71 Appointment Book Printer Jeremy Smith The following program produces an appointment book on an Epson printer. This may be changed to any printer by modifying the codes in lines 160-260 to match your printer’s specs. The appointment book comes out one week to a page and looking like this: June/July 1987 ____________________________________________________ 29 Monday ____________________________________________________ 30 Tuesday ____________________________________________________ 1 Wednesday ____________________________________________________ 2 Thursday ____________________________________________________ 3 Friday ____________________________________________________ 4 Saturday ____________________________________________________ 5 Sunday ____________________________________________________ The size of the page can be set to any height and width by modifying the values in lines 340-370. Two pages are printed side by side and so on normal 8.5 x 11 paper the widest would be about 3.5 inches, and the longest would be 10 or so inches. The final product is double sided; this is accomplished by having you turn the paper over and putting the paper through a second time. The program prompts for starting and ending date and takes care of everything else. The only other 2 prompts are to align the paper (setting the top of the paper in the printer), and then a pause to turn the paper over. After each of these pauses press "f CONT" to continue. If you key the program in use "\" instead of "DIV" and "1e3" instead of "1000", otherwise the lines might be too long to key in. Or you could just split the line up at some logical point. I shall provide the program to anyone who sends a cassette tape and stamped addressed envelope, if you’d rather not key the program in. I wrote the program in January because I could find no suitable appointment book, and so I offer no apologies for an odd approach to the coding which I’m sure could suffer a great deal of optimizing. 10 ! -------------------------------------------------------------- 20 ! Make an appointment book 30 ! Copied right 1987, Jeremy Smith [11] (6676) {185A} <11> 40 ! 1735 NE Seavy Avenue, Corvallis OR 97330 USA (503) 752-0634 50 ! ______________________________________________________________ 60 ! To use just: 70 ! 1. Load the program and press RUN 80 ! 2. Then disengage the printer and untangle the paper 90 ! 3. Set lines 160,260 to reflect your printer control codes to your printer 100 ! 4. Set parameters W, M, P, H @ lines 340,370 to produce the size of calander you want 110 ! 5. Go back to step 1. with renewed patience, RUN, and follow the User terse instructions 120 ! ---------------------------------- 130 ! Printer Control Characters. Set according to your printer 140 ! Needs DSPLEX71 to recognizes LF$, FF$, CR$, EC$ as chr$(10), (12), (13) & (27)! 150 ! __________________________________ 160 PRINTER IS ‘:Printer’ ! Assumes that RESTOREIO & all the HP-IL junk has been done 170 DESTROY R$,B0$,B1$,U0$,U1$ 180 PRINT EC$&’@’; ! Reset printer 190 PRINT EC$&’8'; ! Ignore paper out sensor 200 PRINT CHR$(15); ! Compressed character mode 210 ! PRINT chr$(fotonch) ! No automatic LineFeed with Carriage Return 220 ! R$=EC$&’D’ ! 1/2 reverse Line Feed, used for printers where you can’t disable auto Line Feed 230 B0$=EC$&’H’ ! Double strike mode off 240 B1$=EC$&’G’ ! Double strike mode on 250 U0$=EC$&’-’&CHR$(0) ! Underline mode off 260 U1$=EC$&’-’&CHR$(1) ! Underline mode on 270 ! ---------------------------------- 280 ! Initialize Variables 290 ! __________________________________ 300 ! |<------------------W columns in M inches-------------------------------------- ------>+ 310 ! |<----S$---->+<--S1$-->|<----L-(P")---->|<-S2$->+<--S1$-->|<----L-(P")---->|<- S2$->+ 320 ! |<----S$---->+<--S1$-->|<------L------>|<-S2$->+<--S1$-->|<------L------>|<- S2$->+ 330 DESTROY W,M,P,H,S$,E$,X,U,F 340 W=132 ! Set W to total column width of printer, according to print pitch set above 350 M=7.75 ! Maximum width of print on a page, in inches (do printer self test & measure) 360 P=3.00 ! Width of printed part of appointment book in inches 370 H=6.75 ! H is total height in inches of appointment book(assumes prints 6 lines/inch) 380 INPUT "Start date : ",DATE$;S$ 390 INPUT " End date : ",DATE$;E$ 400 D=DATE @ SETDATE S$ 410 SETDATE FND(-MOD(DATE DIV 1000*365+MOD(DATE,1000),7)+1) @ F=DATE ! Save 4 Flip side 420 ! The above line sets date to Monday of week of starting date. 430 SETDATE E$ 440 X=(DATE DIV 1000*365+MOD(DATE,1000)-(F DIV 1000*365+MOD(F,1000))) DIV 28+1 450 U=X @ SETDATE F 460 DESTROY L$,M$,D$,S$,H$,S1$,S2$,S3$,L,V,B,T,Z,Y 470 DIM L$[64],M$[132],D$[42],S$[56],H$[64] 480 D$=’ Sun Mon TuesWednes Thurs Fri Satur’ 490 M$=’January February March April May June July August SeptemberOctobe 500 M$=M$&’r November December’ 510 S1$[.5*W/M,.5*W/M]=’ ‘ @ S2$[.25*W/M,.25*W/M]=’ ‘ ! S1 = 1/2" = .5*(W/M) columns, S2 = 1/4" 520 L=P*W/M ! L = Line length = P" = P*(W/M) columns 530 S$[W*(.5-(P+3/4)/M),W*(.5-P+3/4)/M]=’ ‘ ! S$ = Spacer = W(.5-(p+3/4)/M) columns 540 H$[L,L]=’ ‘ @ L$[1,1]=’_’ @ L$[L,L]=’_’ @ L$=U1$&L$&U0$ 550 V=(H*6-3) DIV 7 ! V is # lines per day 560 B=(H*6-(V*7)) DIV 2 ! B is # lines at bottom 570 T=H*6-(V*7)-B ! T is # lines at top (unrounded) 580 ! ---------------------------------- 590 ! Main Program 600 ! __________________________________ 610 DISP ‘Align paper’ @ PRINT CHR$(7); @ PAUSE 620 FOR Z=1 TO 2 630 FOR Y=1 TO X ! X calculated @ line 440 640 GOSUB ‘PrintPg’ 650 PRINT FF$ 660 SETDATE FND(21) 670 NEXT Y @ SETDATE D 680 IF NOT FLAG(0) THEN DISP ’Turn paper over& align’ @ PRINT CHR$(7); @ PAUSE 690 SFLAG 0 @ X=U @ SETDATE F @ IF FLAG(0) THEN SETDATE FND(21) ELSE SETDATE FND(7) 700 S3$=S1$ @ S1$=S2$ @ S2$=S3$ ! Flipping! 710 NEXT Z 720 CFLAG 0 @ SETDATE D @ DISP ‘Now cut and paste!’ @ END 730 ! ---------------------------------- 740 ! Print two weeks 750 ! __________________________________ 760 ‘PRINTPG’: 770 PRINT S$;’|’;S1$;H$;S2$;CHR$(8)&’|’;S1$;H$;S2$;CHR$(8)&’|’ 780 PRINT S$;CHR$(8)&’-+’;S1$;H$;S2$;CHR$(8)&CHR$(8)&’-+- ’;S1$;H$;S2$;CHR$(8)&CHR$(8)&’+-’ 790 FOR I=1 TO FLOOR(CEIL(T*2)/2) @ PRINT @ NEXT I ! Print lines @ top; subterfuge is ~ROUND 800 GOSUB ‘Month’ 810 PRINT S$;S1$;B1$;H1$;S2$;S1$; ! Print 1st month$ heading 820 IF FLAG(0) THEN SETDATE FND(-14) ELSE SETDATE FND(14) 830 GOSUB ‘Month’ 840 PRINT H1$;CR$;R$;R$;S$;S1$;L$;S2$;S1$;L$;B0$ ! Print 2nd month$ heading & underline 850 IF FLAG(0) THEN SETDATE FND(14) ELSE SETDATE FND(-14) 860 FOR N=1 TO 7 870 PRINT S$;S1$; 880 GOSUB ‘DOW’ 890 PRINT H0$;S2$;S1$; ! Print 1st date & DOW 900 IF FLAG(0) THEN SETDATE FND(-14) ELSE SETDATE FND(14) 910 GOSUB ‘DOW’ 920 PRINT H0$&CR$;R$;R$; ! Print 2nd date & DOW 930 IF FLAG(0) THEN SETDATE FND(14) ELSE SETDATE FND(-14) 940 FOR I=1 TO V-1 @ PRINT @ NEXT I 950 IF MOD(DATE DIV 1000*365+MOD(DATE,1000),7)=5 THEN PRINT B1$; 960 PRINT S$;S1$;L$;S2$;S1$;L$;B0$ 970 SETDATE FND(1) @ NEXT N 980 FOR I=1 TO B @ PRINT @ NEXT I ! Print bottom lines 990 PRINT S$;CHR$(8)&’-+’;S1$;H$;S2$;CHR$(8)&CHR$(8)&’-+- ’;S1$;H$;S2$;CHR$(8)&CHR$(8)&’+-’ 1000 PRINT S$;’|’;S1$;H$;S2$;CHR$(8)&’|’;S1$;H$;S2$;CHR$(8)&’|’ 1010 RETURN 1020 ! ---------------------------------- 1030 ! Prepare weekly heading 1040 ! (If next month is January it still prints the previous year -as in December/January 1986 1050 ! __________________________________ 1060 ‘MONTH’: 1070 DESTROY H0$ @ DIM H0$[L] ! This is here to get around a silly system bug! 1080 H0$=TRIM$(M$[(VAL(DATE$[4,5])-1)*9+1,VAL(DATE$[4,5])*9]) ! This month$ 1090 SETDATE FND(7) @ DESTROY H1$ @ DIM H1$[L] 1100 H1$=TRIM$(M$[(VAL(DATE$[4,5])-1)*9+1,VAL(DATE$[4,5])*9]) ! Next month$ 1110 IF H0$#H1$ THEN H0$=H0$&’/’&H1$ 1120 SETDATE FND(-7) 1130 DESTROY H1$ @ DIM H1$[L] ! This is here to get around a silly system bug! 1140 IF FLAG(O) THEN H1$=H0$&’ 19'&DATE$[1,2] @ H1$[L]=’ ‘ 1150 IF NOT FLAG(0) THEN H1$=’19'&DATE$[1,2]&’ ‘&H0$ @ H1$[0,0]=H$[1,L-LEN(H1$)] 1160 RETURN 1170 ! ---------------------------------- 1180 ! DOW 1190 ! __________________________________ 1200 ‘DOW’: 1210 DESTROY H0$ @ DIM H0$[L] 1220 IF FLAG(0) THEN 1230 ELSE 1260 1230 H0$=STR$(VAL(DATE$[7,8]))&’ ‘&TRIM$(D$[MOD(DATE DIV 1000*365+MOD(DATE,1000),7)*6+1][1,6]) 1240 H0$=H0$&’day’ @ H0$[L]=’ ‘ 1250 RETURN 1260 H0$=TRIM$(D$[MOD(DATE DIV 1000*365+MOD(DATE,1000),7)*6+1][1,6]&’day’)&’ ‘&STR$(VAL(DATE$[7,8])) 1270 H0$[0,0]=H$[1,L-LEN(H0$)] 1280 RETURN 1290 ! ---------------------------------- 1300 ! This resets the date by J days 1310 ! Leap years are blithley ignored; leap seconds were accidentally overlooked 1320 ! but that’s only ~500 shopping days until we are affected (Christmas ’88) 1330 ! __________________________________ 1340 DEF FND(J) 1350 J=DATE DIV 1000*365+MOD(DATE,1000)+J-1 1360 FND=J DIV 365*1000+MOD(J,365)+1 1370 END DEF 1380 ! ---------------------------------- 1390 ! Error Messages 1400 ! __________________________________ 1410 ! Looking for variables... 1420 BEEP 1225,.025 @ DISP ‘ERR: Working...’ 1430 ! Sufficient Memory ! 1440 ! Prodigal bit returns 1450 ! Internal mouse restless 1460 ! Bit Nap 1470 ! Looking for worms 1480 ! Screening for Viruses 1490 ! Located a forth loop! 1500 ! Memory almost full 1510 ! & counting 1520 ! Hard core novice 1530 ! Too many keystrokes 1540 ! Almost < 0 !