Code:
DECLARE FUNCTION TinyInput (Question AS STRING ,Original AS STRING) AS STRING
DIM AS STRING*1 temp
DIM AS STRING inputtemp, key
DIM AS INTEGER letternumber, oldlocx, oldlocy
SCREENRES 800, 600, 32
oldlocx = 1
oldlocy = 1
OPEN com "com3: 38400, N, 8, 1,cs0,ds0,cd0,rs" AS #1 '----- Das "com3" muss durch den enstprechenden Port ersetzt werden!!
COLOR RGB(0, 100, 0), RGB(255, 255, 255)
CLS
DO
oldlocx = POS
oldlocy = CSRLIN
PRINT " ";
LOCATE oldlocy, oldlocx
LINE (8*oldlocx-8, 8*oldlocy-1)-(8*oldlocx-8, 8*oldlocy-8), 0
key = INKEY$
IF key <> "" AND key <> CHR(13) THEN
IF key = CHR(27) OR key = CHR(255)+"k" THEN CLOSE #1: system
COLOR RGB(200, 0, 0)
inputtemp = TINYINPUT(">> ", key)
COLOR RGB(0, 100, 0)
FOR letternumber = 1 TO LEN(inputtemp)
PUT #1,, MID(inputtemp, letternumber, 1)
NEXT
PUT #1,, CHR(10)
ENDIF
WHILE LOC(1) > 0
IF key = CHR(27) THEN CLOSE #1: SYSTEM
GET #1,, temp
oldlocx = POS
oldlocy = CSRLIN
PRINT " ";
LOCATE oldlocy, oldlocx
PRINT temp;
WEND
LOOP
CLOSE #1
FUNCTION TinyInput (Question AS STRING ,Original AS STRING) AS STRING
DIM AS INTEGER Cur_line, Cur_pos, Cursorpos
DIM AS STRING key
Cur_line = CSRLIN
Cur_pos = POS
Cursorpos = 2
PRINT Question; Original;
LINE (8*(Cur_pos+LEN(Question)+Cursorpos)-16, 8*Cur_line-1)-(8*(Cur_pos+LEN(Question)+Cursorpos)-16, 8*Cur_line-8), 0
DO
DO
key = INKEY$
LOOP UNTIL key <> ""
IF key = CHR(13) THEN
EXIT DO
ELSEIF key = CHR(8) AND Cursorpos > 1 THEN
Original = LEFT(Original, Cursorpos-2)+RIGHT(Original, LEN(Original)-Cursorpos+1)
Cursorpos = Cursorpos-1
ELSEIF key = CHR(255)+"S" AND Cursorpos < LEN(Original)+1 THEN
Original = LEFT(Original, Cursorpos-1)+RIGHT(Original, LEN(Original)-Cursorpos)
ELSEIF (key = CHR(255)+"M") AND Cursorpos < LEN(Original)+1 THEN
Cursorpos = Cursorpos+1
ELSEIF (key = CHR(255)+"K") AND Cursorpos > 1 THEN
Cursorpos = Cursorpos-1
ELSEIF LEN(key) = 1 AND key <> CHR(27) AND key <> CHR(8) then
Original = LEFT(Original, Cursorpos-1)+key+RIGHT(Original, LEN(Original)-Cursorpos+1)
Cursorpos = Cursorpos+1
END IF
LOCATE Cur_line, Cur_pos+LEN(Question)
PRINT SPACE(LEN(Original)+2);
LOCATE Cur_line, Cur_pos+LEN(Question)
PRINT Original;
LINE (8*(Cur_pos+LEN(Question)+Cursorpos)-16, 8*Cur_line-1)-(8*(Cur_pos+LEN(Question)+Cursorpos)-16, 8*Cur_line-8), 0
LOOP
LOCATE Cur_line, Cur_pos+LEN(Question)
PRINT SPACE(LEN(Original)+2);
LOCATE Cur_line, Cur_pos+LEN(Question)
PRINT Original
TINYINPUT = Original
END FUNCTION
(anbei die *exe falls du keinen FreeBASIC Compiler hast, gibts aber KOSTENLOS auf "freebasic-portal.de")
Lesezeichen