REM =================[ Kaypro label-maker program ]===========================\
\
                        Written by Steve Sanders                              \
                               08/18/84                                       \
                                                                              \
\
	   Compiled with Digital Research CBASIC Compiler CB80                \

	vers$ = "1.3"	REM current version number

REM ----------------------[ copyrights (c) ]----------------------------------\

	copyrt1$ = \
	"Portions of this program are (c) Digital Research  "

	copyrt2$ = \
	"  The rest is (c) 1984 Steven L. Sanders"

REM ---------------------[ define constants ]--------------------------------\

	clr% =		1ah		REM clear screen
	clr$ =		CHR$(clr%)
	eol% =		018h		REM clear to end of line
	eol$ =		CHR$(eol%)
	eos% =		017h		REM clear to end of screen
	eos$ =		CHR$(eos%)
	esc% =		1bh		REM ESCape
	esc$ =		CHR$(esc%)
	bs% =		08h		REM backspace
	bs$ =		CHR$(bs%)
	bell% =		07h		REM console bell		
	bell$ =		CHR$(bell%)
	cr% =		0dh		REM carriage return
	cr$ =		CHR$(cr%)

REM   Kaypro video codes for all new models and any old KP10s

	inv.on$ =	esc$ + "B0"	REM inverse video ON
	inv.off$ =	esc$ + "C0"
	dim.on$ =	esc$ + "B1"	REM half intensity video
	dim.off$ =	esc$ + "C1"
	blink.on$ =	esc$ + "B2"	REM blinking chrs ON
	blink.off$ =	esc$ + "C2"
	under.on$ =	esc$ + "B3"	REM underline ON
	under.off$ =	esc$ + "C3"
	curs.on$ =	esc$ + "B4"	REM cursor ON
	curs.off$ =	esc$ + "C4"

REM  String constants and DEFinitions

	header$ = \
	"                 K A Y P R O   L A B E L   M A K E R  v " +\
	vers$

REM position cursor where needed

	DEF fn.cursor$(v%,h%)
		PRINT esc$ + "=" + CHR$(v%+32) + CHR$(h%+32);
		RETURN
	FEND

REM turns up a clean screen under header

	DEF fn.new.screen%
		PRINT FN.CURSOR$(4,0);eos$;
		RETURN
	FEND

REM turns up a clean screen under header + instruction line

	DEF fn.screen.two%
		PRINT FN.CURSOR$(11,0);eos$;
		RETURN
	FEND

REM time delays

	DEF fn.delay%
		FOR delay1% = 1 TO 5
		FOR delay2% = 1 TO 20000
			NEXT delay2%
			NEXT delay1%
		RETURN
	FEND

	DEF fn.fast.delay%
		FOR delay1% = 1 TO 5
		FOR delay2% = 1 TO 100
			NEXT delay2%
			NEXT delay1%
		RETURN
	FEND

	DEF fn.long.delay%
		FOR delay1% = 1 TO 10
		FOR delay2% = 1 TO 20000
			NEXT delay2%
			NEXT delay1%
		RETURN
	FEND

REM -----------------------[ program begins ]--------------------------------\

banner.screen:

REM excuse me while I show off

	PRINT clr$ + curs.off$		REM cursor off while doodling

	FOR dash% = 1 TO 79
	PRINT inv.on$ + "-" + inv.off$;
	dummy% = fn.fast.delay%
	NEXT dash%
	PRINT header$
	FOR dash% = 1 TO 79
	PRINT inv.on$ + "-" + inv.off$;
	dummy% = fn.fast.delay%
	NEXT dash%

	dummy% = fn.delay%

	PRINT:PRINT:PRINT\
	"                  " + inv.on$ +\
	" Copyright (c) 1984  by  Steve Sanders " + inv.off$

	dummy% = fn.delay%

	PRINT:PRINT:PRINT:PRINT:PRINT:PRINT\
"     Designed for use with a  Kaypro computer and a parallel printer."
	PRINT:PRINT\
"     This program  will generate printed labels on  1-up label stock."
	PRINT:PRINT\
"     Labels should be  aligned with the  printhead just at the top of"
	PRINT:PRINT\
"     a label.   You can print  1 sample label before beginning a run."

	dummy% = fn.delay%

	PRINT:PRINT:PRINT:PRINT blink.on$ +\
"     [ press any key ]" + blink.off$

	dummy% = INKEY

start:

	dummy% = fn.new.screen%

	PRINT:PRINT:PRINT:PRINT curs.on$ + inv.on$ +\
	" Enter desired text for the line, do not exceed 30 chrs/line. " +\
	inv.off$

	PRINT:PRINT:PRINT bell$ + dim.on$ +\
	"             " + inv.on$ + "|--------- max 30 chrs --------|" +\
	dim.off$ + inv.off$

input.one:

	INPUT "Line 1 text: ";LINE line1$

	IF LEN(line1$) > 30 \ 
	THEN PRINT bell$ +\
	"[ Maximum entry is 30 characters - Please re-enter ]";:\
	dummy% = fn.long.delay%:\
	PRINT cr$ + eol$;:\
	GOTO input.one

	dummy% = fn.screen.two%

input.two:

	INPUT "Line 2 text: ";LINE line2$

	IF LEN(line2$) > 30 \ 
	THEN PRINT bell$ +\
	"[ Maximum entry is 30 characters - Please re-enter ]";:\
	dummy% = fn.long.delay%:\
	PRINT cr$ + eol$;:\
	GOTO input.two

	dummy% = fn.screen.two%

input.three:

	INPUT "Line 3 text: ";LINE line3$

	IF LEN(line3$) > 30 \ 
	THEN PRINT bell$ +\
	"[ Maximum entry is 30 characters - Please re-enter ]";:\
	dummy% = fn.long.delay%:\
	PRINT cr$ + eol$;:\
	GOTO input.three

	dummy% = fn.screen.two%

input.four:

	INPUT "Line 4 text: ";LINE line4$

	IF LEN(line4$) > 30 \ 
	THEN PRINT bell$ +\
	"[ Maximum entry is 30 characters - Please re-enter ]";:\
	dummy% = fn.long.delay%:\
	PRINT cr$ + eol$;:\
	GOTO input.four

show.label.text:

	dummy% = fn.new.screen%

	PRINT:PRINT:PRINT:PRINT\
	"                     " + inv.on$ + " Your label looks like this: " +\
	inv.off$
	PRINT:PRINT
	PRINT dim.on$ + "                    --------------------------------"
	PRINT "                   | " + dim.off$ + line1$
	PRINT dim.on$ + "                   | " + dim.off$ + line2$
	PRINT dim.on$ + "                   | " + dim.off$ + line3$
	PRINT dim.on$ + "                   | " + dim.off$ + line4$
	PRINT dim.on$ +\
	"                    --------------------------------" +\
								 dim.off$
	PRINT

which.opt:

	PRINT bell$ + dim.on$ +\
	"          [ Options: " + dim.off$ + "<P>rint" + dim.on$ +\
	" a sample, " + dim.off$ + "<R>e-enter" + dim.on$ +\
	" label text ]" + dim.off$;

	answer% = INKEY

	IF UCASE$(CHR$(answer%)) = "P"\
		THEN GOTO print.sample

	IF UCASE$(CHR$(answer%)) = "R"\
		THEN GOTO start

	PRINT cr$ + eol$; : GOTO which.opt

print.sample:

	LPRINTER WIDTH 80

	PRINT
	PRINT line1$
	PRINT line2$
	PRINT line3$
	PRINT line4$
	PRINT

	CONSOLE

print.again:

	dummy% = fn.new.screen%

	PRINT:PRINT:PRINT:PRINT bell$:PRINT\
	"        Print another" + dim.on$ + " sample for printer alignment?" +\
	dim.off$ + "  y/n > ";

	answer% = INKEY

	PRINT UCASE$(CHR$(answer%))
	
	IF UCASE$(CHR$(answer%)) = "N" THEN GOTO how.many

	IF UCASE$(CHR$(answer%)) <> "Y" THEN GOTO print.again

	GOTO print.sample

how.many:

	PRINT:PRINT:PRINT\
	"                 How many" + dim.on$ +\
	" labels are to be printed?" + dim.off$

	PRINT
enter.number:

	INPUT\
	"                     Enter number (0 = quit): ";required%

	IF required% = 0 THEN\
	PRINT clr$:\
	PRINT blink.on$ + "Returning to CP/M" + blink.off$:\
	PRINT bell$:\
	STOP

	IF required% < 0 \
	THEN PRINT cr$ + eol$; : GOTO enter.number

print.labels:

	dummy% = fn.new.screen%

	PRINT:PRINT:PRINT:PRINT:PRINT:PRINT bell$:PRINT\
	"                  >> Now printing  [";required%;"] labels <<"

	PRINT:PRINT curs.off$ +\
	"                    Be sure printer is " + blink.on$ +\
	"ON-LINE." + blink.off$

	dummy% = fn.delay%

	LPRINTER WIDTH 80

	FOR labels% = 1 TO required%

	PRINT
	PRINT line1$
	PRINT line2$
	PRINT line3$
	PRINT line4$
	PRINT

	NEXT labels%

	CONSOLE

more.labels:

	dummy% = fn.new.screen%

	PRINT:PRINT:PRINT:PRINT:PRINT:PRINT dim.on$ +\
	"                 Want to print" + dim.off$ + " more labels?"

	PRINT:PRINT\
	"                 Yes" + dim.on$ + " = More of the same"
	PRINT dim.off$ +\
	"                  No" + dim.on$ + " = Enter text for different label"
	PRINT dim.off$ +\
	"                   Quit" + dim.on$ + " = Return to CP/M"

your.choice:

	PRINT bell$ + curs.on$ +\
	"                        Your choice " + dim.off$ + "(y/n/q) > ";

	answer% = INKEY

	IF UCASE$(CHR$(answer%)) = "Y" THEN\
	PRINT:PRINT: GOTO how.many

	IF UCASE$(CHR$(answer%)) = "N" THEN GOTO start

	IF UCASE$(CHR$(answer%)) <> "Q" \
	THEN PRINT cr$ + eol$; : GOTO your.choice

	PRINT clr$
	PRINT bell$
	PRINT blink.on$ + "Returning to CP/M" + blink.off$

	STOP

REM =======================[ end of program ]===============================\
