DECLARE SUB OUTDATA (KE$)
DECLARE SUB FILEPRINT ()
DECLARE SUB CHANGEDIR ()
DECLARE SUB CUTTEXT (TEXT$)
DECLARE SUB waitplease ()
DECLARE SUB changesettings ()
DECLARE SUB scroll ()
COMMON SHARED msplace
COMMON SHARED mess$, ctx$
COMMON SHARED IPT$, OUTP$

OUTP$ = "MON": REM set to monitor
IPT$ = "KEY"
mess$ = " hit <esc> to exit. QBASCII is a simple keyboard routing program. you can use qbASCII to test printers, com ports and alike."

SCREEN 0, 0, 0
msplace = 1
DO
LOCATE 1, 1: PRINT "[- INPUT FROM "; IPT$; " [- OUTPUT TO "; OUTP$
LOCATE 2, 1: PRINT "["; VL, VR; "]"
LOCATE 3, 1: PRINT "LENGTH"; LEN(TEXT$)
LOCATE 4, 1: PRINT TEXT$; "   "
CALL scroll
  REM VERY IMPORTANT

 KEYBOARD$ = INKEY$: REM ONLY CHECK FOR KEYPRESS

SELECT CASE (IPT$)
 CASE IS = "KEY"
  KE$ = KEYBOARD$


END SELECT

IF KE$ <> "" THEN

     TEXT$ = TEXT$ + KE$
     L = LEN(TEXT$)
     IF L >= 128 THEN CALL CUTTEXT(TEXT$)

L$ = LEFT$(KE$, 1): VL = ASC(L$)
r$ = RIGHT$(KE$, 1): VR = ASC(r$)

IF VL = 0 AND VR = 94 THEN CALL changesettings
IF VL = 0 AND VR = 95 THEN CALL FILEPRINT

END IF


CALL OUTDATA(KE$)
LOOP UNTIL KE$ = CHR$(27)

SUB CHANGEDIR
DO

INPUT "DRIVE NAME <C , A, B >"; DR$
INPUT "DIRECTORY BLANK FOR NONE"; DI$

CHDIR DR$ + ":\"

IF DI$ <> "" THEN CHDIR DI$
FILES


INPUT "IS THIS OK <Y/N>"; OK$
LOOP UNTIL OK$ = "Y"


END SUB

SUB changesettings
REM self explanatory
REM sub is devoted to adjusting QBAscii to your needs


CLS : REM clear screen
DO: REM beginning of loop
 LOCATE 1, 1: PRINT "############################################"
 LOCATE 2, 2: PRINT "#    Change Settings for output            #"
 LOCATE 3, 3: PRINT "#    <enter> exits this menu ."
 LOCATE 4, 4: PRINT "# Output "; OUTP$
 LOCATE 5, 5: PRINT "#  <1> for lpt1 (Printer) , <2> for Aux"
 LOCATE 6, 6: PRINT "#  <3> com1 , <4> com2 "
 KE$ = INKEY$: REM read keyboard

      SELECT CASE (KE$)
       CASE IS = "1"
        OUTP$ = "LPT1"
       CASE IS = "2"
        OUTP$ = "AUX"
       CASE IS = "3"
        OUTP$ = "COM1"
       CASE IS = "4"
        OUTP$ = "COM2"

       END SELECT
     
LOOP UNTIL KE$ = CHR$(13): REM loop until <enter>



CALL waitplease



CLS : REM clear screen
DO: REM beginning of loop 2
 LOCATE 1, 1: PRINT "############################################"
 LOCATE 2, 2: PRINT "#    Change Settings for input            #"
 LOCATE 3, 3: PRINT "#    <enter> exits this menu ."
 LOCATE 4, 4: PRINT "#"
 LOCATE 5, 5: PRINT "#  <1> for (KEYBOARD) , <2> for Aux"
 LOCATE 6, 6: PRINT "#  <3> com1 , <4> com2 "

 LOCATE 7, 7: PRINT "# INPUT  "; IPT$

 KE$ = INKEY$: REM read keyboard

      SELECT CASE (KE$)
       CASE IS = "1"
        IPT$ = "KEY"
       CASE IS = "2"
        IPT$ = "AUX"
       CASE IS = "3"
        IPT$ = "COM1"
       CASE IS = "4"
        IPT$ = "COM2"

       END SELECT



LOOP UNTIL KE$ = CHR$(13): REM loop until <enter>
CLS


KE$ = ""
END SUB

SUB CUTTEXT (TEXT$)


L = LEN(TEXT$)


B$ = RIGHT$(TEXT$, L - 2)
TEXT$ = B$




END SUB

SUB FILEPRINT
FILES
DO
INPUT "D <DONE> C <CHANGE FOR NEW LOCATION"; CH$
CH$ = UCASE$(CH$)
IF CH$ = "C" THEN CALL CHANGEDIR
IF CH$ = "F" THEN FILES
LOOP UNTIL CH$ = "D"

INPUT "NAME OF FILE TO PRINT."; NA$
IF NA$ <> "" THEN

OPEN NA$ FOR INPUT AS #1

DO
 INPUT #1, KE$
 'CALL OUTDATA(KE$)
 LPRINT KE$
 

LOOP UNTIL EOF(1)

CLOSE #1
END IF

END SUB

SUB OUTDATA (KE$)
 SELECT CASE (OUTP$)

 CASE IS = "LPT1"
   LPRINT KE$;


 END SELECT
END SUB

SUB scroll
REM text scrolling takes place here
LOCATE 20, 1: PRINT MID$(mess$, msplace, 70)
L = LEN(mess$)
IF ctx$ <> (TIME$) THEN
   ctx$ = TIME$: msplace = msplace + 1: IF msplace >= (L) THEN msplace = 1
END IF


END SUB

SUB waitplease

LOCATE 21, 1: PRINT " hit spacebar please"

DO
KE$ = INKEY$

LOOP UNTIL KE$ = CHR$(32)

 CLS
END SUB

