But in other news, and good news, my key input routine runs OK in QB64 now!

by Pete (Login The-Universe)
Admin

 
If the key resonse rate could be twice as fast, I think it would be perfect but it is certainly usable now.

BTW - QB64 does not yet support STOP. I noticed that, as I use it for testing, sometimes.

-------------------------

CLS
numofspaces% = 40
LOCATE 10, 29
COLOR 8, 7: PRINT "|";
COLOR 0, 7: PRINT SPACE$(numofspaces%);
COLOR 8, 7: PRINT "|";
COLOR 0, 7
LOCATE 10, 30, 1, 7, 7
startpos% = POS(1)
endpos% = startpos% + numofspaces%
DO
DO
b$ = INKEY$
IF b$ <> "" THEN EXIT DO
LOOP
xx% = CSRLIN: yy% = POS(1)

SELECT CASE b$
CASE CHR$(0) + "K"
mov% = -1: GOSUB action
CASE CHR$(0) + "M"
mov% = 1: GOSUB action
CASE CHR$(0) + "S"
GOSUB wash: GOSUB delete
CASE CHR$(0) + "R"
IF ins% = 0 THEN ins% = -1 ELSE ins% = 0
IF ins% = 0 THEN LOCATE , , 1, 7, 7 ELSE LOCATE , , 1, 7, 30
CASE CHR$(0) + "O"
IF word$ <> "" THEN LOCATE xx%, startpos% + LEN(word$)
CASE CHR$(0) + "G"
LOCATE xx%, startpos%
CASE CHR$(8)
IF yy% > startpos% THEN
LOCATE , POS(1) - 1
yy% = POS(1)
GOSUB wash: GOSUB delete
END IF
CASE CHR$(13)
CLS : LOCATE , , 0: PRINT word$; : SLEEP 2: END
REM Enter your routine here.
CASE CHR$(27)
COLOR 7, 0: SYSTEM
CASE CHR$(32) TO CHR$(126)
key$ = b$: GOSUB action
END SELECT
mov% = 0: key$ = ""
LOOP

action:
IF POS(1) + mov% >= startpos% AND POS(1) + mov% < endpos% THEN
DO
IF key$ <> "" THEN
SELECT CASE ins%
CASE 0
IF LEN(word$) + LEN(key$) > endpos% - startpos% THEN EXIT DO
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 1)
CASE -1
word$ = MID$(word$, 1, POS(1) - startpos%) + key$ + MID$(word$, POS(1) - startpos% + 2)
END SELECT
END IF
IF POS(1) - startpos% >= LEN(word$) - LEN(key$) AND key$ <> "" OR key$ = "" OR ins% = -1 THEN
IF key$ = "" AND mov% = 1 THEN IF POS(1) - startpos% = LEN(word$) THEN EXIT DO
LOCATE , POS(1) + mov%: PRINT key$;
ELSE
LOCATE xx%, startpos%: PRINT MID$(word$, 1, yy% - startpos%); key$; : yy2% = POS(1): PRINT MID$(word$, yy% - startpos% + 2); : LOCATE xx%, yy2%
END IF
EXIT DO
LOOP
END IF
RETURN

wash:
IF POS(1) >= startpos% AND word$ <> "" THEN
LOCATE xx%, startpos% + LEN(word$) - 1
PRINT " ";
LOCATE xx%, yy%
END IF
RETURN

delete:
IF POS(1) - startpos% = 0 THEN
word$ = MID$(word$, 2)
ELSE
word$ = MID$(word$, 1, POS(1) - startpos%) + MID$(word$, POS(1) - startpos% + 2)
END IF
PRINT MID$(word$, yy% - startpos% + 1); : LOCATE xx%, yy%
RETURN

----------------------------


Pete



    
This message has been edited by The-Universe on Mar 16, 2008 1:32 PM

Posted on Mar 16, 2008, 1:32 PM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement