100 S1$="*******************PRINTER***********************"
110 S2$=" "
120 S3$="PRINTER configures the PRISM 80 or 132 for"
130 S4$="software programmable parameters..."
140 S5$="Brian C. Dugle, Major, USAF, 21 Nov 82"
150 S6$=" "
160 S7$="*************************************************"
170 REM
180 REM	******INITIALIZE DEFAULT PARAMETERS*******
190 REM
200 PW=8.5: 	REM	PW=	page width (inches)
210 PL=11: 	REM 	PL= 	paper length (inches)
220 PS=.25: 	REM	PS=	paper offset from left edge printline (inches)
230 ML=1.5: 	REM	ML= 	left margin (inches)
240 MR=1: 	REM 	MR= 	right margin (inches)
250 MB=0: 	REM	MB=	bottom margin (inches)
260 CPI%=0: 	REM	CPI%=	char per inch
270 PRPL%=0: 	REM 	PRPL%= 	proportional selector
280 JUST%=0: 	REM	JUST%= 	justify selector
290 MODE%=2: 	REM	MODE%=	print mode selector (normal/expanded)
300 FONT%=1: 	REM 	FONT%= 	font selection
310 TH%=0: 	REM 	TH%= 	number of horiz tabs
320 TV%=0: 	REM	TV%= 	number of vert tabs
330 LF%=8: 	REM	LF%= 	linefeed size (48ths)
340 N=0:	REM 	N= 	initial paper feed (lines)
350 ROLUP%=4: 	REM	ROLUP%=	superscript linefeed (48ths)
360 ROLDOW%=4: 	REM	ROLDOW%=subscript linefeed (48ths)
370 REM			B= 	linefeed input
380 REM			J%= 	gosub counter
390 REM			K%= 	counter for tab loop
400 REM			MB%=	bottom margin position (48ths)
410 REM 		ML%= 	left margin position (120ths)
420 REM 		MR%= 	right margin position (120ths)
430 REM 		S= 	temp tab position (inches)
440 REM 		TBH%= 	horiz tab position (120ths)
450 REM			TBV%= 	vert tab position (48ths)
460 REM 		V%= 	choice, configuration settings	
470 REM 		W$= 	Y/N answer
480 REM 		X%= 	choice: print, change or quit, etc.
490 REM
500 REM	******DEFINE PROMPT STRING CONSTANTS******
510 REM
520 D$=CHR$(26):REM Clear screen...
530 D0$=CHR$(27)+CHR$(84):REM Deletes to end of line...
540 D1$="Use decimals for fractional margin and page sizes"
550 D2$="Which choice?"
560 DEF FNCURSOR$(YPOS%,XPOS%)=CHR$(13)+CHR$(27)+"="+CHR$(YPOS%+31)+CHR$(XPOS%+31)
570 REM "YPOS" is line number on screen, "XPOS" is column and CHR$(13) is <CR> without LF, resets MBasic Characters per Line counter...
580 D3$=D$+FNCURSOR$(10,2)
590 D4$=FNCURSOR$(12,2)+D0$
600 D5$=FNCURSOR$(15,2)
610 D6$=FNCURSOR$(20,2)
620 D7$=FNCURSOR$(23,2)
700 REM
710 REM ******INITIALIZE PROGRAM******************
720 REM
730 DIM TBV%(8)
740 DIM TBH%(21):REM This is the only subscripted variable with more than 10 values...
750 WIDTH 52: WIDTH LPRINT 255
760 REM
800 REM
810 REM ******FIRST SECTION - CHOOSE DATA*********
820 REM
830 PRINT D$;FNCURSOR$(3,2);S1$:PRINT S2$:PRINT TAB(5) S3$:PRINT TAB(5) S4$
840 PRINT TAB(5) S5$:PRINT S6$:PRINT TAB(3) S7$
850 PRINT FNCURSOR$(11,5);
860 PRINT"Press:"
870 PRINT"	<1> to use default parameters"
880 PRINT"	<2> to read last saved parameters"
890 PRINT"	<3> to select all new print parameters"
900 PRINT D6$;D2$;:X0%=VAL(INPUT$ (1))
910 IF X0%<1 OR X0%>3 THEN PRINT"  <1>, <2>, or <3> response only, please try again...": GOTO 900
920 ON X0% GOSUB 2010,4610,2210
930 REM 
940 REM ***CHECK CODES***
950 PRINT D$:PRINT
960 PRINT"Check the configuration codes:":PRINT
970 PRINT" Page size:";PW;"X";PL;"Left edge is set";PS
980 PRINT"  inches left of 1st printable character"
990 PRINT" Margins: left:";ML;"right:";MR;"and bottom:";MB
1000 PRINT"  leaving";PL-MB;"inches vertical space for text"
1010 ML%=INT((ML-PS)*120):IF ML%<0 THEN ML%=0
1020 MR%=INT((PW-PS-MR)*120):IF MR%>((PW-PS)*120)THEN MR%=(PW-PS)*120-15
1030 M=(MR%-ML%)/120:IF CPI%=0 THEN CPI=13.3
1040 IF CPI%=29 THEN CPI=10
1050 IF CPI%=30 THEN CPI=12
1060 IF CPI%=31 THEN CPI=16.8
1070 M1=M*CPI
1080 PRINT" Printline is";M;"inches long, or";M1;"characters"
1090 PRINT"   at";CPI;"fixed spacing"
1100 IF TH%<=0 THEN PRINT" No horizontal tabs set":GOTO 1170
1110	PRINT" Horizontal tabs set at:";
1120	FOR K%=1 TO TH%
1130		PRINT TBH%(K%)/120; 
1140		IF TH%-K%=1 THEN PRINT"and";
1150	NEXT
1160	PRINT"inches from zero print position"
1170 IF TV%<=0 THEN PRINT" No vertical tabs set":GOTO 1240
1180	PRINT" Vertical tabs set at:";
1190	FOR K%=1 TO TV%
1200		PRINT TBV%(K%)/48;
1210		IF TV%-K%=1 THEN PRINT"and";
1220	NEXT
1230	PRINT"inches from top of form"
1240 PRINT" Print mode: ";:IF MODE%=2 THEN PRINT"Normal" ELSE PRINT"EXPAND"
1250 PRINT" Font:";FONT%;"is ";:IF FONT%=1 THEN PRINT"Correspondence" ELSE PRINT"Draft"
1260 IF CPI%=0 THEN PRINT" No character size set, printer defaults to SWs 1      and 2 or last software setting" ELSE PRINT" Char code:";CPI%;" (29=10cpi, 30=12, 31=16.8)"
1270 PRINT" Proportional print ";:IF PRPL%=1 THEN PRINT"ON" ELSE PRINT"OFF"
1280 PRINT" Justified print ";:IF JUST%=1 THEN PRINT"ON" ELSE PRINT"OFF"
1290 PRINT" Linefeed set to";LF%;"48ths inches, or";48/LF%;"lpi"
1300 PRINT" Initial paper position";N;"lines from top"
1310 PRINT D7$;"Are the settings correct <Y/N>?";:W$=INPUT$ (1)
1320 IF W$="Y" OR W$="y" GOTO 1610
1330 REM
1400 REM ***SELECT CODES TO CHANGE***
1410 PRINT D$:PRINT
1420 PRINT"Select which configuration to set:":PRINT
1430 PRINT"	<1> Paper Size"
1440 PRINT"	<2> Margins (left, right, bottom)"
1450 PRINT"	<3> Tab settings (horiz and vert)"
1460 PRINT"	<4> Print Mode"
1470 PRINT"	<5> Character size/Font"
1480 PRINT"	<6> Proportional print"
1490 PRINT"	<7> Justification (at printer)"
1500 PRINT"	<8> Initial paper feed"
1510 PRINT"	<9> Linefeed size (incl sub/supr script)"
1520 PRINT"	<0> All"
1530 PRINT D6$;D2$;:V%=VAL(INPUT$ (1))
1540 PRINT D3$;:ON V%+1 GOSUB 2210,3310,3110,4110,3710,3510,3810,3910,4010,4410
1550 GOTO 950:REM Return to display to check values...
1580 REM
1590 REM ******SEND OR SAVE GOOD DATA*************
1600 REM
1610 PRINT D3$;"Do you want to send these to the printer or save":PRINT" on disk?"
1620 PRINT"	 <0>=No, quit"
1630 PRINT"	 <1>=Yes, just save these settings on disk"
1640 PRINT"	 <2>=Yes, just send to printer, do not save"
1650 PRINT"	 <3>=Yes, send to printer and save on disk"
1660 PRINT D6$;D2$;:X1%=VAL(INPUT$ (1))
1670 IF X1%<0 OR X1%>3 THEN PRINT"  <0>, <1>, <2>,or <3> only please...": GOTO 1660
1680 ON X1%+1 GOSUB 2010,5210,4810,2110
1690 END
1700 REM ******CONTROL SUBROUTINES*****************
2000 REM
2010 RETURN:REM Goes back to display section without changing default settings...
2090 REM
2100 REM ***SEND & SAVE***
2110 GOSUB 4810:REM First LPRINT to Printer...
2120 GOSUB 5210:REM Then save on disk...
2130 RETURN
2190 REM
2200 REM ***LOOP THRU ALL INPUTS***
2210 FOR J%=1 TO 9
2220	ON J% GOSUB 3310,3110,4110,3710,3510,3810,3910,4010,4410
2230 NEXT
2240 RETURN
2990 REM
3000 REM ******INPUT/CHANGE SUBROUTINES************
3090 REM
3100 REM ***MARGINS***
3110 PRINT D3$;"Select the margins desired:"
3120 PRINT"	<1> left= 1, right= 1, bottom= 0 (WordStar)"
3130 PRINT"	<2> left=.5, right=.5, bottom=.8 (LLISTs)"
3140 PRINT"	<3> Other"
3150 PRINT D6$;D2$;:X2%=VAL(INPUT$ (1))
3160 IF X2%<1 OR X2%>3 THEN PRINT"<1>, <2>, or <3> only please...":GOTO 3150
3170 IF X2%=1 THEN ML=1:MR=1:MB=0
3180 IF X2%=2 THEN ML=.5:MR=.5:MB=.8
3190 IF X2%<>3 GOTO 3250
3200 PRINT D3$;D1$
3210 PRINT D4$;:INPUT"Left margin SIZE desired: <in>; <CR>";ML
3220 PRINT D4$;:INPUT"Right margin SIZE desired: <in>; <CR>";MR
3230 PRINT D5$;"Use a bottom margin for printing program listings":PRINT"and so on, leave at zero for printing WordStar":PRINT"documents"
3240 PRINT D4$;:INPUT"Bottom margin SIZE desired: <in>; <CR>";MB
3250 RETURN
3290 REM
3300 REM ***PAPER SIZE & POSITION***
3310 PRINT D3$;"Select the paper size:"
3320 PRINT"	<1> Single sheet 8.5 x 11, at 'C' mark"
3330 PRINT"	<2> Single sheet 8.5 x 14"
3340 PRINT"	<3> Other"
3350 PRINT D6$;D2$;:X3%=VAL(INPUT$ (1))
3360 IF X3%<1 OR X3%>3 THEN PRINT"<1>, <2>, or <3> only please...":GOTO 3350
3370 IF X3%=1 THEN PW=8.5:PL=11:PS=.25
3380 IF X3%=2 THEN PW=8.5:PL=14:PS=.25
3390 IF X3%<>3 GOTO 3490
3400 PRINT D3$;D1$;
3410 PRINT D4$;:INPUT"Paper width <inches>; <CR>";PW
3420 PRINT D5$;"Input the position of the left edge of the paper"
3430 PRINT"from the leftmost print column.  A positive value"
3440 PRINT"may be read directly from the gage if you have the"
3450 PRINT"sheet feeder."
3460 PRINT D4$;:INPUT"Paper edge position <inches>; <CR>";PS
3470 PRINT D3$;D1$;D5$;"This length must agree exactly with WordStar to":PRINT"avoid text creeping up or down on succeeding pages"
3480 PRINT D4$;:INPUT"Paper length <inches>; <CR>";PL
3490 RETURN
3500 REM ***CHARACTER SIZE & FONT***
3510 PRINT D3$;"Character size:"
3520 PRINT"	<0>=None (old or default value)"
3530 PRINT"	<1>=10 cpi"
3540 PRINT"	<2>=12 cpi"
3550 PRINT"	<3>=16.8 cpi"
3560 PRINT D6$;D2$;:CPI%=VAL(INPUT$ (1))
3570 IF CPI%<0 OR CPI%>3 THEN PRINT"  <0>, <1>, <2>, or <3> only please...": GOTO 3560
3580 IF CPI%>0 THEN CPI%=CPI%+28
3590 PRINT D3$;"Font:"
3600 PRINT"	<1> for correspondence"
3610 PRINT"	<2> for draft"
3620 PRINT D6$;D2$;:FONT%=VAL(INPUT$ (1))
3630 IF FONT%<1 OR FONT%>2 THEN PRINT"  <1> or <2> only please...": GOTO 3620
3640 RETURN
3690 REM
3700 REM ***PRINT MODE***
3710 PRINT D3$;"Mode:"
3720 PRINT"	<1> for EXPANDED (doublewidth) characters"
3730 PRINT"	<2> for NORMAL characters"
3740 PRINT D6$;D2$;:MODE%=VAL(INPUT$ (1))
3750 IF MODE%<1 OR MODE%>2 THEN PRINT"  <1> or <2> only please...": GOTO 3740
3760 RETURN
3790 REM
3800 REM ***PROPORTIONAL***
3810 PRINT D3$;"Do you want the print PROPORTIONAL <Y/N>";:W$=INPUT$ (1)
3820 IF W$="Y" OR W$="y" THEN PRPL%=1 ELSE PRPL%=0:REM Only Y or y response evaluated, all others result in "No" response...
3830 RETURN
3900 REM ***JUSTIFIED***
3910 PRINT D3$;"Do you want the print JUSTIFIED <Y/N>";:W$=INPUT$ (1)
3920 IF W$="Y" OR W$="y" THEN JUST%=1 ELSE JUST%=0
3930 RETURN
3990 REM
4000 REM ***INITIAL LINEFEEDS***
4010 PRINT D$;D5$;"If you have a listing program that inserts linefeeds"
4020 PRINT"to skip over perforations, putting about half that"
4030 PRINT"number of linefeeds here allows equalizing the top"
4040 PRINT"and bottom margins.  Do not use this for WordStar"
4050 PRINT"documents--you can also use Form Set to set the top"
4060 PRINT"line position for listing programs, but do not use"
4070 PRINT"it in WordStar."
4080 PRINT FNCURSOR$(10,2);:INPUT"Number of linefeeds to position paper; <CR>";N
4090 RETURN
4100 REM ***TABS HORIZ/VERT***
4110 PRINT D3$;
4120 INPUT"HOW MANY horizontal tabs (0 to 21); <CR>";TH%:IF TH%<=0 GOTO 4210
4130 IF TH%>21 THEN PRINT"  The max number of horizontal tabs is 21, try again...": GOTO 4120
4140 PRINT:PRINT"Identify tab positions from the left edge of the"
4150 PRINT"paper, in order":PRINT
4160 FOR K%=1 TO TH%
4170	PRINT"Tab #";K%;"(inches from left); <CR>";:INPUT S
4180	TBH%(K%)=INT((S-PS)*120)
4190	IF K%>1 THEN IF TBH%(K%-1)>TBH%(K%) THEN PRINT"Tabs must be in left to right (small to large) order":GOTO 4170
4200 NEXT
4210 PRINT D3$;
4220 INPUT"HOW MANY vertical tabs (0 to 8); <CR>";TV%:IF TV%<=0 GOTO 4310
4230	IF TV%>8 THEN PRINT"The max number of vertical tabs is 8, try again..": GOTO 4220
4240	PRINT:PRINT"Identify tab positions from the top edge"
4250	PRINT"of the paper, in order.":PRINT
4260 FOR K%=1 TO TV%
4270	PRINT"Tab #";K%;"(inches from top); <CR>";:INPUT S
4280	TBV%(K%)=INT(S*48)
4290	IF K%>1 THEN IF TBV%(K%-1)>TBV%(K%) THEN PRINT"Tabs must be in top to bottom (small to large) order":GOTO 4270
4300 NEXT
4310 RETURN
4390 REM
4400 REM ***LINEFEED SIZES***
4410 PRINT D3$;"Linefeed is";LF%;"48ths, select:"
4420 PRINT"	<0> No change, leave at above or"
4430 PRINT"	<1> Change in inches per linefeed or"
4440 PRINT"	<2> In lines per inch (lpi) or"
4450 PRINT"	<3> In 48ths of an inch"
4460 PRINT D6$;D2$;:V%=VAL(INPUT$ (1)):PRINT
4470 IF V%<0 OR V%>3 THEN PRINT"<0>, <1>, <2>, or <3> only please...": GOTO 4460
4480 PRINT D6$;:ON V%+1 GOTO 4540,4490,4510,4530
4490 INPUT"Size of linefeed in inches; <CR>";B
4500	LF%=INT(B*48):GOTO 4540
4510 INPUT"Number of lines per inch; <CR>";B
4520	LF%=INT(48/B+.5):GOTO 4540
4530 INPUT"Number of 48ths inch per linefeed; <CR>";LF%
4540 PRINT D3$;"The printer is set to use a half linefeed (4 48ths":PRINT"inches) for subscripts and superscripts."
4550	PRINT D5$;"Do you want to change these <Y/N>?";:W$=INPUT$ (1)
4560	IF W$="Y" OR W$="y" THEN PRINT"How many 48ths (<0> to <9>)?";:R%=VAL(INPUT$ (1)):ROLUP%=R%:ROLDOW%=R%
4570 RETURN
4590 REM
4600 REM ***INPUT FROM DISK FILE "PRINTER.DAT"***
4610 OPEN "I",#1,"PRINTER.DAT"
4620 INPUT#1,PL,PW,PS,ML,MR,MB,TH%,TV%,LF%,ROLUP%,ROLDOW%,FONT%,MODE%,CPI%,PRPL%,JUST%
4630 IF TH%<1 GOTO 4670
4640	FOR K%=1 TO TH%
4650		INPUT#1,TBH%(K%)
4660	NEXT
4670 IF TV%<1 GOTO 4710
4680	FOR K%=1 TO TV%
4690		INPUT#1,TBV%(K%)
4700	NEXT
4710 CLOSE#1
4720 RETURN
4790 REM
4800 REM ***LPRINT CODES TO PRINTER***
4810 LPRINT CHR$(27)+"J",ML%,MR%,"$";
4820 LPRINT CHR$(27)+"R",FONT%,"$";
4830 IF CPI%<>0 THEN LPRINT CHR$(CPI%);
4840 LPRINT CHR$(27)+"L",(INT((PL*48)+.5));:IF MB<>0 THEN LPRINT (INT((PL-MB)*48));
4850	LPRINT"$";
4860 IF PRPL%=1 THEN LPRINT CHR$(16); ELSE IF CPI%<>0 THEN LPRINT CHR$(6);
4870 IF JUST%=1 THEN LPRINT CHR$(4); ELSE IF CPI%<>0 THEN LPRINT CHR$(5);
4880 LPRINT CHR$(27)+"B",LF%,"$";
4890 IF ROLUP%=4 AND ROLDOW%=4 GOTO 4920
4900	LPRINT CHR$(27)+"C",ROLDOW%,"$";
4910	LPRINT CHR$(27)+"D",(-ROLUP%),"$";
4920 IF N<1 GOTO 4970
4930	WHILE N>.5
4940		LPRINT CHR$(10);
4950		N=N-1
4960	WEND
4970 IF TH%<1 GOTO 5030
4980	LPRINT CHR$(27)+"F";
4990	FOR K%=1 TO TH%
5000		LPRINT TBH%(K%);
5010	NEXT
5020	LPRINT"$";
5030 IF TV%<1 GOTO 5090
5040	LPRINT CHR$(27)+"E";
5050	FOR K%=1 TO TV%
5060		LPRINT TBV%(K%);
5070	NEXT
5080	LPRINT"$";
5090 LPRINT CHR$(MODE%);
5100 RETURN
5190 REM
5200 REM ***SAVE IN FILE "PRINTER.DAT"***
5210 OPEN "O",#1,"PRINTER.DAT"
5220 WRITE#1,PL,PW,PS,ML,MR,MB,TH%,TV%,LF%,ROLUP%,ROLDOW%,FONT%,MODE%,CPI%,PRPL%,JUST%
5230 IF TH%<1 GOTO 5270
5240	FOR K%=1 TO TH%
5250		WRITE#1,TBH%(K%)
5260	NEXT
5270 IF TV%<1 GOTO 5310
5280	FOR K%=1 TO TV%
5290		WRITE#1,TBV%(K%)
5300	NEXT
5310 CLOSE#1
5320 RETURN
5330 END
0	NEXT
5270 IF TV%<1 GOTO 5310
5280	FOR K%=1 TO TV%
5290		WRITE#1,TBV%(K%)
5300	NEXT
5310 CLOSE#1
5320 RETURN
