10 CLEAR
20 '
30 '
40 NOO=54 : PN=1  : SPAC$=" "
50 '
60 '  JUKI.BAS  (C) 1985  by Louie Crew
70 '
72 '  Not to be sold!   Individuals may freely copy.
73 '
74 '  For more information, contact: 
75 '
76 '                                Dr. Louie Crew, English Department
77 '                                Chinese University, Shatin, Hong Kong
78 '
80 '  A Program to print stripped WordStar texts in Juki 6100's true 
90 '     Proportional Spacing
100 ' 
110 ' Here the program enters the default codes for printer 1 (Here a JUKI 6100)
120 TB=8 :  WID=120
130 GOTO 300
140 ' --
200 ' Here the program enters the codes for printer 2 (Here an EPSON)
210 '
220 TB=0 :  WID=80 
230 GOTO 2000
240 ' --
300 ' Here the program enters your addresses.
301 ' You will want to put your own information in the quotations
302 ' and then save the program thus altered.
303 '
310 NAME1$="Name 1: Enter at line 310"
320 ADD1LINE2$="Enter this information at line 320"
330 ADD1LINE3$="Enter information at line 330"
340 ADD1LINE4$="Enter information at line 340"
350 ADD1LINE5$="Enter information at line 350
360 NAME2$="Name 2:  Enter at line 360
370 ADD2LINE2$="Enter info. at line 370
380 ADD2LINE3$="Enter info. at line 380
390 ADD2LINE4$="Enter info. at line 390
400 ADD2LINE5$="Enter info. at line 400
410 ' --
500 WIDTH 90
510 PRINT CHR$(26)
520 WIDTH LPRINT WID
530 PRINT 
540 PRINT "Put a disk with manuscripts in Drive B:
550 PRINT "Then hit any key to continue
560 PRINT
570 PRINT "Type * to return to the SYSTEM"
580 PRINT
590 Z$=INPUT$(1)
600     IF Z$="*" THEN SYSTEM
610 RESET
620 ' --
630 '
700 PRINT "These are your files on drive B:
710 PRINT
720 FILES "B:*.*"
730 PRINT
740 PRINT
750 PRINT "Enter the names of up to 6 files you want to print followed by <>
760 PRINT
770 PRINT "Enter just <> to stop naming files.
780 PRINT
790 INPUT F1$
800 F1$="B:"+F1$
810 NO=1
820 INPUT F2$
830     IF F2$="" THEN 2010
840 F2$="B:"+F2$
850 NO=2
860 INPUT F3$ 
870     IF F3$="" THEN 2010
880 F3$="B:"+F3$
890 NO=3
900 INPUT F4$
910     IF F4$="" THEN 2010
920 F4$="B:"+F4$
930 NO=4
940 INPUT F5$
950     IF F5$="" THEN 2010
960 F5$="B:"+F5$
970 NO=5
980 INPUT F6$
990     IF F6$="" THEN 2010
1000 F6$="B:"+F6$
1010 NO=6
1020 INPUT FILE$
1030 ' --
2000 '
2010 ' PRINT ROUTINE STARTS HERE
2020 '
2030 PRINT
2040 PRINT "1 = BEGIN PRINTING
2050 PRINT "2 = Address envelopes
2060 PRINT "3 = Shift to Printer No. 2 (Epson)
2070 PRINT "4 = Alter other defaults 
2080 PRINT 
2090 PRINT
2100 PRINT
2110 P$=INPUT$(1)
2120    IF P$="1" THEN 3000
2130    IF P$="2" THEN 3000 
2140    IF P$="3" THEN 200
2150    IF P$="4" THEN 14000
2160 PRINT
2170 PRINT "Try again."
2180 PRINT
2190 GOTO 2110
2200 ' --
2210 '
3000 ' FILE ORDER FOR PRINTING IS RE-CALLED
3010 BUMP=0
3020     IF F=>1 THEN 3050
3030 FILE$=F1$
3040 F=1 : GOTO 3200
3050     IF F=>2 THEN 3080
3060 FILE$=F2$
3070 F=2 : GOTO 3200
3080     IF F=>3 THEN 3110
3090 FILE$=F3$
3100 F=3 : GOTO 3200
3110     IF F=>4 THEN 3140
3120 FILE$=F4$
3130 F=4 : GOTO 3200
3140     IF F=>5 THEN 3170
3150 FILE$=F5$
3160 F=5 : GOTO 3200
3170     IF F6$="" OR IF F=6 THEN 21000
3180 FILE$=F6$
3190 F=6 
3200 PRINT 
3210     IF P$="2" THEN 23000
3220     IF FILE$="" THEN 21000
3230 ' --
3240 '
4000 OPEN "I",#1,FILE$
4010 PRINT FILE$ " is now printing."
4020 OPE=0
4030 ROUTE=1
4040 GOTO 22000
4050 B$=LEFT$(A$,1)      
4060     IF B$<>"." THEN 9000
4070 PRINT "Message in the file:  "A$
4080 D=LEN(A$)              
4090     IF D<5 THEN 4300
4100 M=4
4110 WH$=MID$(A$,M,1)
4120     IF WH$="" THEN 4190
4130 WH=ASC(WH$)
4140 WHILE WH=32 OR WH=46
4150 M=M+1
4160 GOTO 4110
4170 ' --
4180 WEND
4190 CONTENT$=MID$(A$,M,D-M+1)
4200 FOR M=1 TO D
4210 CA$=MID$(A$,M,1)
4220 CA=ASC(CA$)
4230     IF CA=>97 AND CA=<122 THEN 4240 ELSE 4260
4240 CA=CA-32
4250 CA$=CHR$(CA)
4260 CAPSA$=CAPSA$+CA$
4270 NEXT M
4280 A$=CAPSA$
4290 CAPSA$=""
4300     IF D<3 THEN 4350
4310 C$=MID$(A$,2,2)
4320     IF C$="FI" THEN 6000
4330     IF C$="DM" THEN 4340 ELSE 4370 
4340 PRINT 
4350     IF ROUTE=1 THEN 22000
4360     IF ROUTE=2 THEN 8040
4370     IF C$="CP" THEN 4380 ELSE 5000
4380 CRY=VAL(CONTENT$)
4390 GOTO 11530
4400 ' -- 
5000     IF C$="PA" OR C$="Pa" OR C$="pa" THEN 11530 
5010     IF ROUTE=2 THEN 8040
5020     IF ROUTE=1 THEN 22000
5030 ' --
5040 '
6000 FILE2$=MID$(A$,5,D-4)
6010 W$=MID$(FILE2$,2,1)
6020     IF W$=":" THEN 8000
6030 FILE2$="B:"+FILE2$
6040 ON ERROR GOTO 7000
6050 GOTO 8000
6060 ' --
7000     IF ERR=53 THEN 7010 ELSE END
7010 PRINT "File " FILE2$ " not found.
7020 PRINT "Hit any key to continue or hit ^C to specify the file from the keyboard
7030 PRINT "If you do the latter, to begin again, type: "
7040 PRINT ,,,," FILE2$
7050 PRINT ,,,," GOTO 8010
7060 Z$=INPUT$(1) : RESUME 8510
7070 ' --
7080 '
8000 OPEN "I",#2,FILE2$
8010     IF EOF (2) THEN 8600
8020 GOTO 8050
8030 ' --
8040     IF EOF (2) THEN 8500
8050 ROUTE=2
8060 GOTO 22000
8070 ' --
8080 '
8500 CLOSE #2 
8510 ROUTE=1      
8520 GOTO 22000
8530 ' --
8540 '
8600 PRINT "Warning!  Your insert " FILE2$ " was not found.
8610 CLOSE #2
8620 ROUTE=1
8630 PRINT
8640 GOTO 22000
8650 ' --
8660 '
9000     IF STAR=0 THEN 10000
9010     IF PN=>STAR THEN 10000
9020 GOTO 11000
9030 ' --
9040 '
10000 LPRINT TAB(TB) A$
10010 ' --
10020 '
11000 CT=CT+1
11010     IF FOOT1=0 AND FOOT2=0 THEN 11500
11020     IF CT=>NOO-3 THEN 11530
11030 GOTO 11510
11040 ' --
11050 '
11500     IF CT=>NOO THEN 11530
11510     IF ROUTE=1 THEN 22000
11520     IF ROUTE=2 THEN 22000
11530     IF STAR=0 THEN 11550
11540     IF PN>=STAR THEN 11550 ELSE 12500
11550     IF FOOT2<>1 THEN 12000
11560 FO=LEN(FOOT2$)            
11570 I=(77-FO)/2+TB             
11580 LPRINT
11590 LPRINT
11600 LPRINT TAB(I) FOOT2$      
11610 GOTO 12500                
11620 ' --                      
11630 '
12000     IF FOOT1<>1 THEN 12500
12010     IF PN<2 THEN 12500
12020 FO=LEN(FOOT1$)
12030 I=(77-FO)/2+TB
12040 LPRINT TAB(I) FOOT1$ TAB(TB) "Page "PN
12050 ' --
12060 '
12500 LPRINT CHR$(12)  
12510 IF FINIS<>1 THEN 13000
12520 FINIS=0 : CT=0 : GOTO 3000
12530 ' --
13000     IF ROUTE=2 THEN 13500
13010     IF EOF(1) THEN 13020 ELSE 13500
13020 CLOSE  :  GOTO 19050
13030 ' --
13040 '
13500 PN=PN+1
13510 CT=0
13520     IF HEADING$="" THEN 13620
13530     IF STAR=0 THEN 13550
13540     IF PN=>STAR THEN 13550 ELSE 13610
13550 H=LEN(HEADING$)
13560 I=((77-H)/2)+TB
13570 LPRINT TAB(I) HEADING$ TAB(77) "Page "PN
13580 LPRINT
13590 LPRINT
13600 LPRINT
13610 CT=CT+4
13620     IF ROUTE=1 THEN 22000
13630     IF ROUTE=2 THEN 22000
13640 ' --
13650 '
14000 PRINT "Enter a heading to appear w/ page # after no. 1?  (Y/N)
14010 PRINT
14020 P$=INPUT$(1)
14030     IF P$="Y" OR P$="y" THEN 14040 ELSE 14500
14040 LINE INPUT "The heading.....",HEADING$
14050 PRINT
14060 GOTO 17010
14070 ' --
14080 '
14500 PRINT "1 = Enter a footing to appear with page number from page 2 onward.
14510 PRINT "2 = Use NAME 1 AND ADDRESS 1 and address as a footing on all pages, w/o a page no.
14520 PRINT "3 = Use NAME 2 and ADDRESS 2 as footing on all pages, w/o page no.
14530 PRINT "4 = NO FOOTING AT ALL
14540 PRINT
14550 P$=INPUT$(1)
14560 T=VAL(P$)
14570     IF T=1 THEN 15000
14580     IF T=2 THEN 15500
14590     IF T=3 THEN 16000
14600     IF T=4 THEN 17000
14610 PRINT "Try again. " 
14620 PRINT 
14630 GOTO 14500
14640 ' --
15000 PRINT
15010 FOOT1=1  : FOOT2=0
15020 LINE INPUT "Footing to appear with page number: ",FOOT1$
15030 GOTO 17000
15040 ' --
15500 FOOT2=1  : FOOT1=0
15510 FOOT2$=NAME1$+SPAC$+ADD1LINE2$+SPAC$+ADD1LINE3$+SPAC$+ADD1LINE4$+SPAC$+ADD1LINE5$  
15520 GOTO 17000
15530 ' --
16000 FOOT2=1  : FOOT1=0
16010 FOOT2$=NAME2$+SPAC$+ADD2LINE2$+SPAC$+ADD2LINE3$+SPAC$+ADD2LINE4$+SPAC$+ADD2LINE5$
16020 ' --
17000 PRINT
17010 PRINT "Change the number of lines per page (default 55)? (Y/N)
17020 PRINT
17030 P$=INPUT$(1)   :  PRINT
17040     IF P$="Y" OR P$="y" THEN 17050 ELSE 18000
17050 INPUT "The new number? ", NOO
17060 NOO=NOO-1 : PRINT
18000 PRINT "Begin at a later page number?   (Y/N)
18010 PRINT
18020 Z$=INPUT$(1)  :  PRINT
18030     IF Z$="Y" OR Z$="y" THEN 18040 ELSE 18050
18040 INPUT "Page at which to begin the print ";STAR
18050 PRINT
18060 PRINT "You have checked all defaults now programmed.
18070 PRINT
18080 GOTO 2000
18090 ' --
19000 CLOSE
19010 PRINT
19020 PRINT "You have finished printing " FILE$
19030     IF FOOT1=0 AND FOOT2=0 THEN 19040 ELSE 20000
19040 LPRINT CHR$(12)
19050 CT=0
19060 PRINT
19070 GOTO 3000
19080 ' --
20000 FINIS=1 : NEED=NOO-CT
20010 FOR MOV=1 TO NEED
20020 LPRINT
20030 NEXT MOV
20040 GOTO 11550
20050 ' --
20060 '
21000 PRINT
21010 PRINT "You have finished printing the files which you named on this disk.
21020 PRINT
21030 GOTO 10  
21040 ' --
21050 '
22000 ' Input
22010     IF ROUTE=2 THEN 22050
22020     IF EOF (1) THEN 19000
22030 LINE INPUT #1,A$
22040 GOTO 22070
22050     IF EOF (2) THEN 8500
22060 LINE INPUT #2,A$
22070 GOTO 4050
22080 ' --
22090 '
23000     IF FILE$="" THEN 25000
23010 OPEN "I",#1,FILE$
23020 PRINT
23030 PRINT "You are printing envelopes to the addressees in "FILE$
23040     IF EOF(1) THEN 24500
23050 LINE INPUT #1,T$
23060 A$=""
23070 T=LEN(T$)
23080     IF ENV=1 THEN 23500
23090 ENV$=MID$(T$,4,2)
23100     IF ENV$="X " OR ENV$= "x " THEN 23110 ELSE 23040
23110 ID$=RIGHT$(T$,T-5)
23120 ENV=1
23130 GOSUB 26000
23140     IF Z$<>"6" THEN 23160
23150 ENV=0
23160 GOTO 23040
23170 ' --
23500     IF T$<>"" THEN 24000
23510 FOR REMOVES=1 TO 35
23520 PRINT
23530 NEXT REMOVES
23540 ENV=0
23550 GOTO 23040
23560 ' --
24000 LPRINT TAB(35) T$
24010 GOTO 23040
24020 ' --
24500 CLOSE
24510 PRINT
24520 PRINT "You have finished printing the envelopes in " FILE$
24530 PRINT
24540 GOTO 3000
24550 ' --
25000 PRINT
25010 PRINT "You have finished envelopes to all files specified.
25020 PRINT
25030 GOTO 30
25040 ' --
25050 '
26000 PRINT
26010 PRINT "1 = NO RETURN ADDRESS
26020 PRINT "2 = NAME 1, ADDRESS1 
26030 PRINT "3 = NAME 2, ADDRESS1
26040 PRINT "4 = NAME 1, ADDRESS2
26050 PRINT "5 = NAME 2, ADDRESS2
26060 PRINT "6 = SKIP this envelope altogether.
26070 PRINT
26080 PRINT "Choose only when your envelope is in place regarding " 
26090 PRINT ID$
26100 PRINT
26110 Z$=INPUT$(1)
26120     IF Z$="1" OR Z$="6" THEN RETURN
26130     IF Z$="2" OR Z$="4" THEN 26500
26140     IF Z$="3" OR Z$="5" THEN 27000
26150 PRINT "Try again."
26160 PRINT
26170 GOTO 26110
26180 ' --
26500 LPRINT NAME1$
26510     IF Z$="4" THEN 27500
26520 GOTO 27020
26530 ' --
27000 LPRINT NAME2$
27010     IF Z$="5" THEN 27500
27020 LPRINT ADD1LINE2$
27030 GOTO 27510
27040 ' --
27500 LPRINT ADD2LINE2$
27510 LPRINT ADD1LINE3$
27520 LPRINT ADD1LINE4$
27530 LPRINT ADD1LINE5$
27540 LPRINT
27550 LPRINT
27560 RETURN
D2LINE2$
27510 LPRINT ADD1LINE3$
27520 LPRINT ADD1LINE4$
27530 LPRINT 